C Language Interview Question Answer

What is a built-in function?

Built-function is also known as library functions that are provided by the system to make the life of a developer easy by assisting them to do certain commonly used predefined tasks.

The definition or name of built-in function can be different in every programming language. For example, If we want to print something on screen in c programming then we need use printf() function while in PHP we have to use echo() function for that.

Why is C known as a mother language?

C is one of the most widely used programming languages of all time, and C compilers are available for the majority of available computer architectures and operating systems. The C language has formed the basis for many languages including C++, Java, JavaScript, Go, Rust, Limbo, LPC, C#, PHP, Python, Perl, Verilog, and C-shell.

Why C language is so popular?

One of the very strong reasons why C programming language is so popular and used so widely is the flexibility of its use for memory management. But there are some other reason for C language popularity like, Speed and Raw Performance, Closeness to Operating System, procedural, structured and mid-level programming language.

What is procedural language?

As per name suggests in procedural language's code is written as a sequence of instructions. In those instruction user can simply specify “what to do” and “how to do”. These instructions are executed in the sequential order. This code contains a systematic order of statements, functions and commands to perform specific task.

Procedural language is also known as imperative language.


What is structured language?

In structure language, code breaks the program into small parts and solves each problem individually. A structured programming language is the language that supports three patterns: sequence (an ordered list of statements), selection (e.g. if statements) and repetition (e.g. loops).

Why C language is called a mid-level programming language?

C is called a mid-level programming language because it binds the low level and high -level programming language. We can use C language as a System programming to develop the operating system as well as an application which perform some specific task.

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

The printf() function is used for printing formatted content to the screen. This function format output content with help of format specifiers.

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

What is local variable and global variable in c programming?

The concept of local variable and global variable is defined based on life cycle of variable.

The Local variable is defined and used for specific block of code or function. We can't use this variable in any statements outside of that scope.

The Global Variable is generally defined outside of function or block. The scope of a variable is available throughout the program and life of global variable is exists until program is being executed. So we can use it in any block/function of code.

What is a static variable in C programming?

A variable which is declared as static is called static variable. As per name suggests, the value of static variable retains same for entire program. Static variable can be accessed from any part of program.

What are the key features of C programming language?

Key features of c programming are :

  • Portability: It is a platform-independent language.
  • Modularity: In C programming program breaks into small blocks or modules
  • Flexibility: The possibility of a programmer to control the language.
  • Speed: C comes with support for system programming and hence it compiles and executes with high speed when compared with other high-level languages.


What are the basic data types of C?

Here are basic data types of C programming language:

  • Int – Represent the number (integer)
  • Float – Number with a fraction part.
  • Double – Double-precision floating-point value
  • Char – Single character
  • Void – Special purpose type without any value.

How many types of data type in C Language?

C language supports 2 type of data types:

Primary data types: Primary data types are known as fundamental data types.Some primary data types are integer(int), floating point(float), character(char) and void.

Derived data types: Derived data types are derived from primary datatypes. Some derived data types are array, structure, union and pointer.

What is constant and variable in C?

C language supports 2 type of data types:

Constant: A constant is a value or an identifier whose value cannot be changed in a program. identifier also can be defined as a constant.


const double PI = 3.14

Here, value of PI = 3.14 is remains constant for entire program.

What is reserved keywords? How many reserved keywords are there in C?

Words that are restricted for general use while writing a program, i.e., for using as a name for a variable, function, structure, etc. are called reserved keywords.

The C programming language has 32 reserved keywords.

What is Dynamic Memory Allocation?

Dynamic Memory Allocation is the procedure of allotting memory to the C program and its variables during runtime. While malloc(), calloc(), and realloc() allocates memory, the free() function frees up the used memory space.


Explain the difference between calloc() and malloc() functions.

Here are key differance between malloc() and calloc() function :

  • Malloc() function will create a single block of memory of size specified by the user while in calloc() function can assign multiple block of memory.
  • Malloc function contains garbage value while in calloc function doesn't contain garbage value because it always initialized to zero.
  • malloc() function returns only starting address and does not make it zero on the other hand, calloc() function returns the starting address and make it zero.
  • malloc does not initialize memory whereas calloc performs memory initialization.

Explain Static Memory Allocation in C programming.

Unlike Dynamic Memory Allocation that allocates memory in runtime, Static Memory Allocation allocates the memory during compilation. Static Memory Allocation does not let you increase the memory allocation while the C program is being executed.

What is the difference between ++a and a++?

The ++a is called prefix increment. First, the value stored in the variable a gets incremented and then gets assigned to the same variable. Whereas, a++ is called postfix increment. The value stored in the variable a gets incremented after the execution of the particular line.

What are types of C programming Loops?

C programming language provide us 3 types of loops:

  1. For Loop : Executes a sequence of statements multiple times and abbreviates the code that manages the loop variable.
  2. While Loop : Executes code of block while a given condition is true. While loop test condition every time before running code.
  3. Do While Loop : It is more like a while statement, except that it tests the condition at the end of the loop body. Which means, it run once even condition is not true.

What is the difference between while (0) and while (1)?

While(1) is an infinite loop. Which means it will run till a break statement occurs. Whereas, While(0) does the exact opposite of this. When while(0) is used, it means the conditions will always be false. Thus, as a result, the program will never get executed.

Describe the difference between = and == symbols in C programming?

The = is the assignment operator which is used to assign the value of the right-hand side to the variable on the left-hand side.

The == is the comparison operator which is used to compare the value or expression on the left-hand side with the value or expression on the right-hand side.


Explain memory leak in C?

Memory leak happens when a memory created in a heap remains undeleted. This can lead to additional memory usage and, thus, affect the performance of a program. This is exactly why the issue of memory leak must be addressed.

What are command-line arguments?

Command line arguments are used to control a program from outside, we supply the command line argument parameter to the program when the main method is invoked. Following is syntax of Command line argument:

int main(int argc, char *argv[]) 

What is pointer in C programming language?

A pointer is a variable whose value is the address of another variable, i.e., direct address of the memory location. Like any variable or constant, you must declare a pointer before using it to store any variable address. Following is syntax for defining pointer :

Syntax :

data_type *variable_name

Example :

int *ip;
double *dp;
float *fp;
char *chp;

What is the void pointer in C programming?

The void pointer is not associated with any data types. It points to some data location in the storage means points to the address of variables. It is also called general purpose pointer.

Example :

int main() {
   int a = 10;
   void *p;
   p = &a;
   printf("Integer variable is = %d", *( (int*) p) );
   return 0;

Output :

Integer variable is = 10