Static variables are local to the block in which it is
declared. But its value wont disappear when the comes out of that block. Its value is initialized to zero by default. It is initialized only once. 2.What is a pointer? Derived data type. The value stored in it is the memory address of variable(any basic data type). Allows C to support dynamic memory management. 3.What is a structure? User defined data type. Mechanism for packing different data types. Keyword struct is used to declare a structure. 4.What are the differences between arrays and structures? No. Arrays Structures 1.collection of elements of collection of elements of similar data type. different data types. 2. Derived data type. User defined data type. 3. Declared and used like Designed first before declaring built-in data type. and using it. 5.In header files whether functions are declared or defined? Functions are defined in header files. 6.What are the differences between malloc and calloc? No. malloc calloc 1. Allocates single block of Allocates multiple blocks of Memory. memory. 2. garbage value is stored in Allocated memory blocks are Allocated memory. initialized to zero. 7.What are macros? They are preprocessors which processes the source code before compilation. Keyword #define are used to define a macro. Syntax: #define pi 5 Replaces every occurrence of pi in source code by 5. Advantages: We can change values of a constant at all places in program by making a change in macro definition. Drawbacks: Inefficient because compiler can generate faster and compact code for constants. Variable may get altered somewhere in the program so that it wont be a constant. 8.Difference between call by value and call by reference: Both are argument passing mechanisms. No. call by value call by reference 1. values of variables are passed address of variables arepassed. 2. changes to arguments in called changes to arguments in called function wont affect arguments function will affect arguments in calling function. in calling function. 3. function returns a value. function can have multiple return values. 10. Where are auto variables stored? Stack 11. Contents storage location Local variables stack . Global variables heap. Static variables memory. C program instructions memory. Register variables CPU registers. 12. Difference between arrays and linked list: No. arrays linked list 1. linear data structure non-linear data structure. 2. handles similar data elements handles different data elements. 3. memory is allocated statically. Memory is allocated at run time. 4. data are stored contiguously. Non contiguous data storage. 5. size of array is fixed. Can store any no. of elements. 6. can suffer from memory No possibility for memory shortage. shortage. 13. Enumerations: User defined data type. Used to invent our own data type and define what values the variables of this data type can take. Keyword enum is used. Eg: enum result {Pass=1,Fail=0 }; Helps to reduce programming errors. 14)variable scope local local to the block Global entire program. extern entire program. Static local to the block in which the variable is defined. Register local to the block in which the variable is defined. 15. Register variables: These variables are stored in CPU registers. A variable which is used at many places in a program can be a register variable. Advantages: They can be accessed faster than the variables stored in memory. Kernel Kickers Placement Session - Frequently Asked Questions in 'C'