I this post we have provided part 2 of the most common C interview questions along with answers. We recommend you to try to answer the questions, before referring to the given answer. If you find any mistake or a better alternate solution we are happy to see your suggestions and comments
1. What is the difference between function name and a function pointer?
Ans : Both are same. The function name in itself is a function pointer.
2. How to define a function pointer variable?
Ans : syntax return_type (* fn_ptr_var)(arg_list);
example int (* add) (int lval, int rval);
3. How to declare a type to a function pointer?
Ans : syntax typedef return_type (* type_name)(arg_list);
example typedef int (* MathFuncPtr_t) (int, int);
4. What is the difference between parameter and argument?
Ans : Parameter is the list of type of input given to a function and argument is the actual values passed to those parameters.
5. What is pass by reference and pass by value?
Ans : Pass the value of a variable is pass by value and passing the address of the value is pass by reference
6. How to return more than one value from a function?
Ans : There is no way to return more than one value but can set the value to the variables which are passed by reference
7. What is implicit and explicit function calls?
Implicit Call : function_name ( arg_list )
Explicit Call : (*function_name) ( arg_list )
both implicit and explicit function call does the same.
8. What is indirect function call?
Ans : Assign a function to a function pointer variable and calling the function using the function pointer variable is indirect function call.
9. What is function declaration, definition and function call?
Ans : Writing down the return type, function name and parameter list data type is declaration, writing down what the function actual has to do is definition and passing the control flow to the function definition is calling the function
10. Write down the declaration of printf() and scanf() functions?
int scanf(const char *fmt, …);
int printf(const char *fmt, …);