Q 1. What is a static function ?
Ans 1: A static function is a function whose scope is limited to the current source file. Scope refers to the visibility of a function or variable.
Q 2. Is it possible to execute code even after the program exits the main() function ?
Ans 2: C library consists of a function named atexit() that can be used to perform “cleanup” operations when your program terminates. You can set up a set of functions you want to perform automatically when your program exits by passing function pointers to the atexit() function.
Q 3. Is using exit() the same as using return?
Ans 3: No. The exit() function is used to exit from your program and the return function is used to return from a function and return control to the calling function.
Q 4. Explain the use of fflush() function ?
Ans 4: It is used to empty the buffer associated with the o/p stream.
Q 5. What is the difference b/w malloc() and calloc() ?
Ans 5: malloc allocates uninitialized memory while calloc initializes the allocated memory with a constant (0).
malloc uses single parameter while calloc uses 2 parameters to initialize memory.
Q 6. What is virtual function ?
Ans 6: A virtual function is a member function that is declared within a base class and redefined by a derived class.
Q 7. How many arguments can be used in a function ?
Ans 7: As such c language doesn’t put any restriction on number of arguments but arguments greater than 8 is not preferred.
Q 8. What is the output of the following program?
swap(int x,int y)
Ans 8: 10 22 (duplicate copy of arguments are generated on calling a function)
Q 9. What will be the output of the following code ?
Ans 9: Some address will be printed as function names are just addresses. Similarly output() is also a function and its address will be printed.
Q 10. What will be the output of the following code ?
printf(“%d”,scanf(“%d”,&i)); // value 10 is given as input here
Ans 10: 1 as Scanf returns number of items read successfully. So number of items read is 1.