C Programming Interview Questions and Answers

C Programming Interview Questions And Answers for beginners/experienced professionals from Codingcompiler. These Adobe Analytics interview questions were asked in various interviews conducted by top multinational companies across the globe. We hope that these interview questions on C programming  will help you in cracking your next C Programming job interview. All the best and happy learning..

C programming Interview Questions 

  1. What is C programming Language?
  2. Why is C known as a mother language?
  3. What are the key features of C programming language?
  4. What is the use of header files in C?
  5. Can a program be compiled without the main() function?
  6. What are the basic data types in C?
  7. What are different storage class specifiers in C?
  8. What is scope of a variable? How are variables scoped in C?
  9. What is a pointer on pointer?
  10. Distinguish between malloc() & calloc() memory allocation

C programming Interview Questions and Answers

Q. What is C programming Language?

 C Language Introduction. C is a procedural programming language. It was initially developed by Dennis Ritchie in the year 1972. It was mainly developed as a system programming language to write an operating system. Like syntax of Java, PHP, JavaScript, and many other languages are mainly based on C language.

Q. Why is C known as a mother language?

C is known as a mother language because most of the compilers and JVMs are written in C language. Most of the languages which are developed after C language has borrowed heavily from it like C++, Python, Rust, javascript, etc. It introduces new core concepts like arrays, functions, file handling which are used in these languages

Q. What are the key features of C programming language?

C is a platform-dependent language.

C offers the possibility to break down a large program into small modules.

Also, the possibility of a programmer to control the language.

C comes with support for system programming and hence it compiles and executes with high speed when compared to other high-level languages.

Q. What is the use of header files in C?

Header files contain the definitions and set of rules of the functions being used in the programs.

For example, when you use printf() or scanf() in your program, you nee to include stdio.h library function. Else your compiler will show an error. This is because, the standard input and output functions printf() and scanf() are stored in this header file.

So similarly every header file stores a set of predefined functions which makes it easy to program.

Q. Can a program be compiled without the main() function?

Yes, compilation is possible, but the execution is not possible. However, if you use #define, we can execute the program without the need of main().

For Example:

#include <stdio.h> 

#define start main    

void start() {    



Q. What are the basic data types in C?

Int – Used to represent a number (integer)

Float – Used to represent a decimal number

Double – Used to represent a decimal number with highest precision(digits after the decimal point)

Char – Single character

Void – Special purpose type without any value

Q. What are different storage class specifiers in C?

Ans: auto, register, static, extern

Q. What is scope of a variable? How are variables scoped in C?

Ans: 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.

Q. What is a pointer on pointer?

It’s a pointer variable which can hold the address of another pointer variable. It de-refers twice to point to the data held by the designated pointer variable.

Eg: int x = 5, *p=&x, **q=&p;

Therefore ‘x’ can be accessed by **q.

Q. Distinguish between malloc() & calloc() memory allocation.

Both allocates memory from heap area/dynamic memory. By default calloc fills the allocated memory with 0’s.

Frequently asked C programming Interview Questions and Answers

Q. What is keyword auto for?

By default every local variable of the function is automatic (auto). In the below function both the variables ‘i’ and ‘j’ are automatic variables.

void f() {

   int i;

   auto int j;


NOTE − A global variable can’t be an automatic variable.

Q. What is a static variable?

A static local variables retains its value between the function call and the default value is 0. The following function will print 1 2 3 if called thrice.

void f() { 

   static int i; 


   printf(“%d “,i); 


If a global variable is static then its visibility is limited to the same source code.

Q. What is a NULL pointer?

A pointer pointing to nothing is called so. Eg: char *p=NULL.

Q. What do you mean by Dangling Pointer Variable in C Programming?

Ans: A Pointer in C Programming is used to point the memory location of an existing variable. In case if that particular variable is deleted and the Pointer is still pointing to the same memory location, then that particular pointer variable is called as a Dangling Pointer Variable.

Q. What do you mean by a Nested Structure?

Ans: When a data member of one structure is referred by the data member of another function, then the structure is called a Nested Structure.

Q. What is a C Token?

Ans: Keywords, Constants, Special Symbols, Strings, Operators, Identifiers used in C program are referred to as C Tokens.

Q. What is a preprocessor?

And: In simple terms, a C Preprocessor is just a text substitution tool and it instructs the compiler to do required pre-processing before the actual compilation. We’ll refer to the C Preprocessor as CPP. Returns true if this macro is not defined. Tests if a compile time condition is true.

Q. What is the task of preprocessor?

The preprocessor provides the ability for the inclusion of header files, macro expansions, conditional compilation, and line control. In many C implementations, it is a separate program invoked by the compiler as the first part of translation.

Q. What is a C Token?

Ans: Keywords, Constants, Special Symbols, Strings, Operators, Identifiers used in C program are referred to as C Tokens.

Q. What is the process to create increment and decrement stamen in C?

Ans: There are two possible methods to perform this task.

1) Use increment (++) and decrement (-) operator.

Example When x=4, x++ returns 5 and x- returns 3.

2) Use conventional + or – sign.

When x=4, use x+1 to get 5 and x-1 to get 3.

Q. Describe Wild Pointers in C?

Ans: Uninitialized pointers in the C code are known as Wild Pointers. These are a point to some arbitrary memory location and can cause bad program behavior or program crash.

Q. What are the valid places to have keyword “Break”?

Ans) The purpose of the Break keyword is to bring the control out of the code block which is executing. It can appear only in Looping or switch statements.

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

printf(): The printf() function is used to print the integer, character, float and string values on to the screen.

Following are the format specifier:

  • %d: It is a format specifier used to print an integer value.
  • %s: It is a format specifier used to print a string.
  • %c: It is a format specifier used to display a character value.
  • %f: It is a format specifier used to display a floating point value.

scanf(): The scanf() function is used to take input from the user.

Advanced C Programming Interview Questions and Answers

Q. What is recursion in C?

When a function calls itself, and this process is known as recursion. The function that calls itself is known as a recursive function.

Recursive function comes in two phases:

  1. Winding phase
  2. Unwinding phase

Winding phase: When the recursive function calls itself, and this phase ends when the condition is reached.

Unwinding phase: Unwinding phase starts when the condition is reached, and the control returns to the original call.

Example of recursion

#include <stdio.h>  

int calculate_fact(int);  

int main()  


 int n=5,f;  

 f=calculate_fact(n); // calling a function  

 printf(“factorial of a number is %d”,f);  

  return 0;  


int calculate_fact(int a)  




      return 1;  



  return a*calculate_fact(a-1); //calling a function recursively.  



factorial of a number is 120

Q. What is static memory allocation?

  • In case of static memory allocation, memory is allocated at compile time, and memory can’t be increased while executing the program. It is used in the array.
  • The lifetime of a variable in static memory is the lifetime of a program.
  • The static memory is allocated using static keyword.
  • The static memory is implemented using stacks or heap.
  • The pointer is required to access the variable present in the static memory.
  • The static memory is faster than dynamic memory.
  • In static memory, more memory space is required to store the variable.

For example:  

int a[10];  

The above example creates an array of integer type, and the size of an array is fixed, i.e., 10.

Q. What is a union?

The union is a user-defined data type that allows storing multiple types of data in a single unit. However, it doesn’t occupy the sum of the memory of all members. It holds the memory of the largest member only.

In union, we can access only one variable at a time as it allocates one common space for all the members of a union.

Syntax of union

union union_name  




Member_variable n;  

}[union variables]; 

Q. Write an example program of Union?


union data  


    int a;      //union members declaration.  

    float b;  

    char ch;  


int main()  


  union data d;       //union variable.  




  printf(“value of a is %d”,d.a);  


  printf(“value of b is %f”,d.b);  


  printf(“value of ch is %c”,d.ch);  

  return 0;  



value of a is 1085485921

value of b is 5.600022

value of ch is a

In the above example, the value of a and b gets corrupted, and only variable ch shows the actual output. This is because all the members of a union share the common memory space. Hence, the variable ch whose value is currently updated.

Q. What is an auto keyword in C?

In C, every local variable of a function is known as an automatic (auto) variable. Variables which are declared inside the function block are known as a local variable. The local variables are also known as an auto variable. It is optional to use an auto keyword before the data type of a variable. If no value is stored in the local variable, then it consists of a garbage value.

C programming Interview Questions and Answers for experienced

Q. Why N++ Executes Faster Than N+1?

Answer :

The expression n++ requires a single machine instruction such as INR to carry out the increment operation whereas n+1 requires more instructions to carry out this operation.

Q. Differentiate Between A Linker And Linkage?

Answer :

A linker converts an object code into an executable code by linking together the necessary build in functions. The form and place of declaration where the variable is declared in a program determine the linkage of variable.

Q. What Is Storage Class And What Are Storage Variable?

Answer :

A storage class is an attribute that changes the behavior of a variable. It controls the lifetime, scope and linkage. There are five types of storage classes.






Q. How Do You Print An Address?

Answer :

The safest way is to use printf () (or fprintf() or sprintf()) with the %P specification. That prints a void pointer (void*). Different compilers might print a pointer with different formats. Your compiler will pick a format that’s right for your environment.

If you have some other kind of pointer (not a void*) and you want to be very safe, cast the pointer to a void*:

printf (“%Pn”, (void*) buffer);

Q. What Does It Mean When A Pointer Is Used In An If Statement?

Answer :

Any time a pointer is used as a condition, it means “Is this a non-null pointer?” A pointer can be used in an if, while, for, or do/while statement, or in a conditional expression.

Q. Is Null Always Defined As 0?

Answer :

NULL is defined as either 0 or (void*)0. These values are almost identical; either a literal zero or a void pointer is converted automatically to any kind of pointer, as necessary, whenever a pointer is needed (although the compiler can’t always tell when a pointer is needed).

Q. How Do You Print Only Part Of A String?


/* Use printf () to print the first 11 characters of source_str. */

printf (“First 11 characters: ‘%11.11s’n”, source_str);

Q. Can A Variable Be Both Const And Volatile?

Answer :

Yes. The const modifier means that this code cannot change the value of the variable, but that does not mean that the value cannot be changed by means outside this code. For instance, in the example in FAQ 8, the timer structure was accessed through a volatile const pointer. The function itself did not change the value of the timer, so it was declared const. However, the value was changed by hardware on the computer, so it was declared volatile. If a variable is both const and volatile, the two modifiers can appear in either order.

Q. What is modular programming?


Modular programming is a program design technique in which a large program is divided into sub programs/ functions that are called modules, it improve maintainability of a program. It makes software development, debug, modify, update faster and easy.

Q. What is full form of ARM ?

Advance RISC(Reduced Instruction Set Computer) Machine.

Top C programming Interview Questions and Answers

Q. What is the difference between printf() and puts() ?


The function printf() writes the data on standard output device with the ability of formatted string using %c, %d, %s, %20s .. etc and printf does not add new line after displaying text.

 int printf(const char *format, …);

puts() writes the string on standard output device and add new line after displaying text.

 int puts(const char *s);

Q. What is sizeof() ?

It is a built in operator in c language, it returns the size of any variable/value in bytes.


Q. What are the return type of malloc() and calloc(), how can we use?

malloc() and calloc() both functions return void* (a void pointer), to use/capture the returned value in pointer variable we convert it’s type.

Suppose we create memory for 10 integers then we have to convert it into int*.



int *ptr;


Here, malloc() will return void* and ptr variable is int* type, so we are converting it into (int*).

Q. What are called and calling functions?

Parent function which calls any function is known as calling function and the function which is being called is know as calling function.

Consider the examples:


int main()




Here, abcFunc() is called within main() function, so main() is called, while abcFunc() is calling function.

Q. Difference b/w sentinel control loop & counter control Loop?

In Counter Controlled loop, we know that exactly how many times loop body will be executed while in Sentinel Controlled loop we don’t know about the loop recurrence, Execution of loop is based on condition not counter.

Consider the example:

/*****Counter Control loop*****/



    //Body of the loop


/*****Sentinel Control loop*****/

while( n>0)



Q. What is an rvalue?

rvalue can be defined as an expression that can be assigned to an lvalue. The rvalue appears on the right side of an assignment statement.

Unlike an lvalue, an rvalue can be a constant or an expression, as shown here:

int x, y;

x = 1;               /* 1 is an rvalue; x is an lvalue */

y = (x + 1);         /* (x + 1) is an rvalue; y is an lvalue */

And assignment statement must have both an lvalue and an rvalue. Therefore, the following statement would not compile because it is missing an rvalue:

int x; x = void_function_call() /* the function void_function_call() returns nothing */

If the function had returned an integer, it would be considered an rvalue because it evaluates into something that the lvalue, x, can store.

Q. What does the modulus operator do?

The modulus operator (%) gives the remainder of two divided numbers. For instance, consider the following portion of code:

x = 15/7

If x were an integer, the resulting value of x would be 2. However, consider what would happen if you were to apply the modulus operator to the same equation:

x = 15%7

The result of this expression would be the remainder of 15 divided by 7, or 1. This is to say that 15 divided by 7 is 2 with a remainder of 1.

The modulus operator is commonly used to determine whether one number is evenly divisible into another. For instance, if you wanted to print every third letter of the alphabet, you would use the following code:

int x;

for (x=1; x<=26; x++)

     if ((x%3) == 0)

          printf(“%c”, x+64);

The preceding example would output the string “cfilorux”, which represents every third letter in the alphabet.

Q. What are different techniques for making hash function?

Techniques for making hash function.

Truncation Method

This is the simplest method for computing address from a key.In this method we take only a part of the key as address.

Midsquare Method

In this method the key is squared and some digits from the middle of this square are taken as address.

Folding Method

In this technique, the key is divided into different part where the length of each part is same as that of the required address, except possibly the last part.

• Division Method (Modulo-Division)

In Modulo-Division method the key is divided by the table size and the remainder is taken as the address of the hash table.

–>Let the table size is n then

H (k) =k mod n

Q. Is using exit() the same as using return?

No, the exit() function is used to exit your program and return() controls the operating system.

The return statement is used to return from a function and return control to the calling function. If you make a return from the main() function, you are essentially returning control(operating system) to the calling function. In this case, the return statement and exit() function are similar.

Q. What is an lvalue?

An lvalue is an expression to which a value can be assigned. The lvalue expression is located on the left side of an assignment statement whereas an rvalue is located on the right side of an assignment statement.

Each assignment statement must have an lvalue and an rvalue. The lvalue expression must refer a storable variable in memory. It cannot be a constant.

Q. What is Treap?

Treap is a Balanced Binary Search Tree, but not guaranteed to have height as O(Log n). The idea is to use Randomization and Binary Heap property to maintain balance with high probability. The expected time complexity of search, insert and delete is O(Log n).

–>Each node of Treap maintains two values.

 Key follows standard BST ordering (left is smaller and right is greater)

 Priority Randomly assigned value that follows Max-Heap property.


  1. Core Java Interview Questions
  2. JSF Interview Questions
  3. JSP Interview Questions
  4. JPA Interview Questions
  5. Spring Framework Interview Questions
  6. Spring Boot Interview Questions
  7. Core Java Multiple Choice Questions
  8. 60 Java MCQ Questions And Answers
  9. Aricent Java Interview Questions
  10. Accenture Java Interview Questions
  11. Advanced Java Interview Questions For 5 8 10 Years Experienced
  12. Core Java Interview Questions For Experienced
  13. GIT Interview Questions And Answers
  14. Network Security Interview Questions
  15. CheckPoint Interview Questions
  16. Page Object Model Interview Questions
  17. Apache Pig Interview Questions
  18. Python Interview Questions And Answers
  19. Peoplesoft Integration Broker Interview Questions
  20. PeopleSoft Application Engine Interview Questions

Leave a Comment