C Interview Questions and Answers

What is Recursive Functions?

The function can be called by another function and can call itself from a statement inside the body of the function itself. When function called itself then is said to be recursive.

What is the purpose of main() function?

C program execution starts and ends with the main() function .
The main() function can returns an integer value to the environment that called the program. Where return 0; indicates program is terminated normally.

Can we compile a program without main() function?

Yes, we can compile program but it can't be executed.

What is the use of printf() and scanf() functions?

The printf() function is used for output and scanf() function is used for input.

What is the difference between the while and do-while statements?

The main difference is that in the while statement, the conditional expression is evaluated at the top of the loop, while in the do-while statement, the conditional expression is evaluated at the bottom of the loop. 
Therefore, do-while statement are guaranteed to be executed at least once even conditional expression will be fail.

What is the difference between break and continue statement?

break is a keyword used to terminate the loop or exit from the block. The control jumps to next statement after the loop or block.
continue is a keyword used for skipping the current iteration and go to next iteration of the loop.

What goto statement do?

The goto statement is to enable the programmer to jump unconditional from one spot to some other spot in the code. Uses of goto statement is not recommended because it can make program unreliable and hard to debug.

What Is a Pointer?

A pointer is a special variable that contains the memory address of another variable or function. 
Whereas address-of operator (&) can be used to obtain the address of a variable and   the asterisk (*) in a variable declaration tells the compiler that the declared variable is a pointer.

What are the usage of pointer in C?

A pointer is used in the following cases 
Accessing array elements
Dynamic memory allocation
Call by Reference
Data Structures like tree, graph, linked list etc.

What is Null Pointers?

A pointer is said to be a null pointer when its right value is either null or 0. Remember, a null pointernever point to valid data.

What is a pointer on pointer?

Pointer variable can hold the address of another pointer variable is known as a pointer on pointer.

What is the advantage of declaring void pointers?

The void pointer can be converted anytime into any generic type pointer by casting operator.

What is a pointer to a function?

A pointer can hold the reference of the function is called pointer to a function.

What is the difference between actual and formal parameters?

The parameters sent to the function at calling end are called as actual parameters while at the receiving of the function definition called as formal parameters.

What is Pass by Value & Pass by Reference?

Pass by Value:In this method,the value of each of the actual arguments in the calling function is copied into corresponding formal arguments of the called function.In pass by value,the changes made to formal arguments in the called function have no effect on the values of actual arguments in the calling function.

Pass by Reference:In this method,the addresses of actual arguments in the calling function are copied into formal arguments of the called function. This means that using these addresses, we would have an access to the actual arguments and hence we would be able to manipulate them.

What Is an Array?

An array is a collection of variables with same data type. Item of array is called an element. All elements in an array are referenced by the name of the array and are stored in a set of consecutive, adjacent memory slots.the index of an array starts from 0.

Latest Updates