Delicious Digg Facebook Favorites More Stumbleupon Twitter

Thursday 13 September 2012

Interview questions part1


                         Interview Questions

          

  • What is the output of printf(“%d”)?
        There is nothing after %d so compiler will show in
        output window garbage value.
  • Difference between “calloc(…)” and “malloc(…)”?
        calloc(…) allocates a block of memory for an array
        of elements of a certain size.
        malloc(…) allocated bytes of memory and not blocks
        of memory like calloc(…).

  • Can I include other file in place of .h with #include?
        Yes! The preprocessor will include whatever the file name
        you mention, eg: #include<macros.inc>, the file
        macros.inc   will be included.

  • Difference between “printf(…)” and “sprintf(…)”?
       sprintf() this method writes data to the character array.
       printf() Used to write data to the standard output device.

  • How to reduce a final size of executable?
       It can be reduced using dynamic linking for libraries.

  • What are the different storage classes in C?
       Automatic, static and allocated are three storage classes in C.

  • Difference between Strings and character arrays?
       String will have static storage duration, character array
       will not. Unless you explicitly specify with static keyword.

  • How to determine the size of an allocated portion of memory?
       Using free() method.

  • Difference between static memory allocation and dynamic memory allocation?
       In case of Static memory compiler allocates the
       required   memory space for a declared variable, whereas
       in dynamic memory allocation functions malloc( ) or
       calloc( ) is used to get memory dynamically.

  • What is the difference between arrays and pointers?
       Pointers(*) are used to manipulate data using the
       address, Arrays are collection of similar data types.

0 comments:

Post a Comment