Q.1 In header files whether functions are declared or defined?
Ans: Functions are declared within header file. That is function prototypes exist in a header file,not function bodies. They are defined in library (lib).
Q.2 What is the difference between "calloc(...)" and "malloc(...)"?
Ans: 1. calloc(...) allocates a block of memory for an array of elements of a certain size. By default the block is initialized to 0. The total number of memory allocated will be (number_of_elements * size).malloc(...) takes in only a single argument which is the memory required in bytes. malloc(...) allocated bytes of memory and not blocks of memory like calloc(...). 2.malloc(...) allocates memory blocks and returns a void pointer to the allocated space, or NULL if there is insufficient memory available.calloc(...) allocates an array in memory with elements initialized to 0 and returns a pointer to the allocated space. calloc(...) calls malloc(...) in order to use the C++ _set_new_mode function to set the new handler mode.
Q.3 What are enumerations?
Ans: They are a list of named integer-valued constants. Example:enum color { black , orange=4,yellow, green, blue, violet };This declaration defines the symbols “black”, “orange”, “yellow”, etc. to have the values “1,” “4,” “5,” … etc. The difference between an enumeration and a macro is that the enum actually declares a type, and therefore can be type checked.
Q.4 What is storage class? What are the different storage classes in C?
Ans: Storage class is an attribute that changes the behavior of a variable. It controls the lifetime, scope and linkage. The storage classes in c are auto, register, and extern, static, typedef.
Q.5 What is the difference between a NULL Pointer and a NULL Macro?
Ans: Null pointer is a pointer that is pointing nothing while NULL macro will used for replacing 0 in program as #define NULL 0 .
Q.6 What is friend function?
Ans: The function declaration should be preceded by the keyword friend.The function definitions does not use either the keyword or the scope operator ::. The functions that are declared with the keyword friend as friend function.Thus, a friend function is an ordinary function or a member of another class.
Q.7 What is preincrement and post increment?
Ans: ++n (pre increment) increments n before its value is used in an assignment operation or any expression containing it. n++ (post increment) does increment after the value of n is used.
Q.8 What are macros? What are its advantages and disadvantages?
Ans: Macros are abbreviations for lengthy and frequently used statements. When a macro is called the entire code is substituted by a single line though the macro definition is of several lines.The advantage of macro is that it reduces the time taken for control transfer as in case of function.The disadvantage of it is here the entire code is substituted so the program becomes lengthy if a macro is called several times
Q.9 What the advantages of using Unions?
Ans: When the C compiler is allocating memory for unions it will always reserve enough room for the largest member.
Q.10 What is near pointer?
Ans: A near pointer is 16 bits long. It uses the current content of the CS (code segment) register (if the pointer is pointing to code) or current contents of DS (data segment) register (if the pointer is pointing to data) for the segment part, the offset part is stored in a 16 bit near pointer. Using near pointer limits the data/code to 64kb segment.
Q.11 What is a file pointer?
Ans: The pointer to a FILE data type is called as a stream pointer or a file pointer. A file pointer points to the block of information of the stream that had just been opened.
Q.12 What is the purpose of main() function?
Ans: The function main() invokes other functions within it.It is the first function to be called when the program starts execution.
• It is the starting function.
• It returns an int value to the environment that called the program.
• Recursive call is allowed for main( ) also.
• It is a user-defined function.
• It is the starting function.
• It returns an int value to the environment that called the program.
• Recursive call is allowed for main( ) also.
• It is a user-defined function.
Q.13 Define inheritance?
Ans: Inheritance is the process by which objects of one class acquire properties of objects of another class.
Q.14 Define destuctors?
Ans: A destructor is called for a class object when that object passes out of scope or is explicitly deleted.A destructors as the name implies is used to destroy the objects that have been created by a constructors.Like a constructor , the destructor is a member function whose name is the same as the class name but is precided by a tilde.
Q.15 In C, why is the void pointer useful? When would you use it?
Ans: The void pointer is useful because it is a generic pointer that any pointer can be cast into and back again without loss of information.
Q.16 Are pointers integer?
Ans: No, pointers are not integers. A pointer is an address. It is a positive number.