Q1. What is a static function?
Ans1: It is a function whose scope is limited to the current source file. Scope refers to the visibility of a function or variable.
Q2. Is it possible to execute code even after the program exits the main()?
Ans2: 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 pointers to the atexit().
Q3. Using exit() is same as using return()?
Ans3: No. The exit() is used to exit from your program and the return is used to return from a function and return control to the calling.
Q4. Explain the use of fflush()?
Ans4: It is used to empty the buffer associated with the o/p stream.
Q5. 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.
Q6. What is virtual function?
Ans6: It is a member function that is declared within a base class and redefined by a derived class.
Q7. How many arguments can be used in a function ?
Ans7: As such c language doesn’t put any restriction on number of arguments to be used but arguments greater than 8 is not preferred.
Q8. What is the output of the following program?
swap(int x,int y)
Ans8: 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.