C Interview Questions


1) What are different storage class specifiers in C?

Register,auto, static, extern are the storage class specifiers in C.


2) What is scope of a variable? How are variables scoped in C?

Scope of a variable is the part of the program where the variable may directly be accessible. In C, all identifiers are lexically (or statically) scoped.


3) What is memory leak? Why it should be avoided?

"Memory leak" occurs when programmers create memory in heap and forget to delete it.


4) What is NULL pointer?

"Null pointer" is a reserved value of a pointer . A pointer of any type has a reserved value.

Each pointer type has its own null value.Conceptually, when a pointer has that null value it is not pointing anywhere.


5) When should we use pointers in a C program?

  1. To get address of a variable.
  2. For achieving pass by reference .
  3. To pass large structures .

6) How will you print "Antarctic Ocean" without semicolon?


7) Can I use "int" data type to store the value of 32769? Why?

No, because "int" data type is capable of storing values from -32768 to32767. To store 32769, you can use "long int" instead.


8) What is debugging?

It is the process of Identifying Errors. The program can't be executed because at compile time errors are found. Debugging ensures the removal of errors.


9) What is wrong in this statement?

An ampersand (&) symbol must be placed before the variable name "whereareyou" .


10) What will be the outcome of the following conditional statement if the value of variable A is 10?

The outcome will be "TRUE". Since the value of A is 10, A >= 10 evaluates to TRUE because A is not greater than 10 but is still equal to 10. A< 25 is also TRUE since 10 is less then 25. Just the same, A!=12, which means A is not equal to 12, evaluates to TRUE. The && operator is follows the rule that if all individual conditions are TRUE, the entire statement is TRUE.


11) What is wrong with this statement? myName = "Atul";

You cannot use the = sign to assign values to a string variable. Instead, use the strcpy() function.

The correct statement would be:


12) What is FIFO?

In C programming, there is a data structure known as queue. In this structure, data is stored and accessed using FIFO format, or First-In-First-Out.


13) What is the difference between the = symbol and == symbol?

The = symbol is used in mathematical operations. It is used to assign a value to a given variable. On the other hand, the == symbol, also known as "equal to" is a relational operator that is used to compare two values.


14) Can the curly brackets { } be used to enclose a single line of code?

"Curly Brackets" are mainly used to group many lines of codes, it will still work without error if you used it for a single line.


15) Write a c program to print "Hello World" without using any semicolon?

Three ways to print “Hello World” in c without using semicolon are: