60 Most Important C Programming Interview Questions And Answers

By – HtmlCssMonk

List of 60 Most Important C Programming Interview Questions with Answers.

C programming language was developed between 1969 and 1973 by Dennis Ritchie at Bell Labs. He used this new programming language to re-implement UNIX operating system.

C is a high-level structured oriented programming language used for general-purpose programming requirements. Basically, C is a collection of its library functions. It is also flexible to add user-defined functions and include those in the C library.

The main usage of C programming language includes Language Compilers, Operating Systems, Assemblers, Text Editors, Print Spoolers, Network Drivers, Modern Programs, Data Bases, Language Interpreters, and Utilities.

Also Try-Test your Skills with Amazing Quizzes.

Let’s get started.

1- What is C language?

C is a mid-level and procedural programming language. The Procedural programming language is also known as the structured programming language is a technique in which large programs are broken down into smaller modules, and each module uses structured code. This technique minimizes error and misinterpretation.

2- Why is C known as a mother language?

C introduced many core concepts and data structures like arrays, lists, functions, strings, etc. Many languages designed after C are designed on the basis of C Language. Hence, it is considered as the mother of all languages.

3- What are the basic Datatypes supported in C Programming Language?

The Datatypes in C Language are broadly classified into 4 categories. They are as follows:

  • Basic Datatypes
  • Derived Datatypes
  • Enumerated Datatypes
  • Void Datatypes

The Basic Datatypes supported in C Language are as follows:

Datatype NameDatatype SizeDatatype Range
short1 byte-128 to 127
unsigned short1 byte0 to 255
char1 byte-128 to 127
unsigned char1 byte0 to 255
int2 bytes-32,768 to 32,767
unsigned int2 bytes0 to 65,535
long4 bytes-2,147,483,648 to 2,147,483,647
unsigned long4 bytes0 to 4,294,967,295
float4 bytes3.4E-38 to 3.4E+38
double8 bytes1.7E-308 to 1.7E+308
long double10 bytes3.4E-4932 to 1.1E+4932

4- What do you mean by the Scope of the variable? What is the scope of the variables in C?

Scope of the variable can be defined as the part of the code area where the variables declared in the program can be accessed directly. In C, all identifiers are lexically (or statically) scoped. 

5- What are the key features in the C programming language?

Features are as follows:

  • Portability: It is a platform-independent language.
  • Modularity: Possibility to break down large programs into small 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.
  • Extensibility: Possibility to add new features by the programmer.

6- What is the process to create increment and decrement statement in C?

There are two possible methods to perform this task.

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

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

  • Use conventional + or – sign.

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

7- What are reserved words with a programming language?

The words that are a part of the standard C language library are called reserved words. Those reserved words have special meaning and it is not possible to use them for any activity other than its intended functionality.

Example: void, return int.

8- Why is C 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 programming to generate menu driven customer driven billing system.

9- Who is the founder of C language?

Dennis Ritchie

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

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.

11- What is the difference between the local variable and global variable in C?

Following are the differences between a local variable and global variable:

Basis for comparisonLocal variableGlobal variable
DeclarationA variable which is declared inside function or block is known as a local variable.A variable which is declared outside function or block is known as a global variable.
ScopeThe scope of a variable is available within a function in which they are declared.The scope of a variable is available throughout the program.
AccessVariables can be accessed only by those statements inside a function in which they are declared.Any statement in the entire program can access variables.
LifeLife of a variable is created when the function block is entered and destroyed on its exit.Life of a variable exists until the program is executing.
StorageVariables are stored in a stack unless specified.The compiler decides the storage location of a variable.

12- What are static variables and functions?

The variables and functions that are declared using the keyword Static are considered as Static Variable and Static Functions. The variables declared using Static keyword will have their scope restricted to the function in which they are declared.

13- Differentiate between calloc() and malloc().

calloc() and malloc() are memory dynamic memory allocating functions. The only difference between them is that calloc() will load all the assigned memory locations with value 0 but malloc() will not.

14- What are the valid places where the programmer can apply Break Control Statement?

Break Control statement is valid to be used inside a loop and Switch control statements.

15- How can we store a negative integer?

To store a negative integer, we need to follow the following steps. Calculate the two’s complement of the same positive integer.

Eg: 1011 (-5)

Step-1 − One’s complement of 5: 1010

Step-2 − Add 1 to above, giving 1011, which is -5

16- What is the difference between Call by Value and Call by Reference?

Following are the differences between a call by value and call by reference are:

Call by valueCall by reference
DescriptionWhen a copy of the value is passed to the function, then the original value is not modified.When a copy of the value is passed to the function, then the original value is modified.
Memory locationActual arguments and formal arguments are created in separate memory locations.Actual arguments and formal arguments are created in the same memory location.
SafetyIn this case, actual arguments remain safe as they cannot be modified.In this case, actual arguments are not reliable, as they are modified.
ArgumentsThe copies of the actual arguments are passed to the formal arguments.The addresses of actual arguments are passed to their respective formal arguments.

17- What is the explanation for the dangling pointer in C?

When there is a pointer pointing to a memory address of any variable, but after some time the variable was deleted from the memory location while keeping the pointer pointing to that location is known as a dangling pointer in C.

18- Describe static function with its usage?

A function, which has a function definition prefixed with a static keyword is defined as a static function. The static function should be called within the same source code.

19- What is the difference between abs() and fabs() functions?

Both functions are to retrieve absolute value. abs() is for integer values and fabs() is for floating type numbers. Prototype for abs() is under the library file < stdlib.h > and fabs() is under < math.h >.

20- Describe Wild Pointers in C?

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

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

‘==’ 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.

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

22- What are the uses of functions in C?

Uses of C function are:

  • C functions are used to avoid the rewriting the same code again and again in our program.
  • C functions can be called any number of times from any place of our program.
  • When a program is divided into functions, then any part of our program can easily be tracked.
  • C functions provide the reusability concept, i.e., it breaks the big task into smaller tasks so that it makes the C program more understandable.

23- 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.

24- Differentiate between Actual Parameters and Formal Parameters.

The Parameters which are sent from main function to the subdivided function are called as Actual Parameters and the parameters which are declared a the Subdivided function end are called as Formal Parameters.

25- Can a C program be compiled or executed in the absence of a main()?

The program will be compiled but will not be executed. To execute any C program, main() is required.

26- What do you mean by a Nested Structure?

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

27- What is the explanation for prototype function in C?

Prototype function is a declaration of a function with the following information to the compiler.

  • Name of the function.
  • The return type of the function.
  • Parameters list of the function.

28- What is the explanation for the cyclic nature of data types in C?

Some of the data types in C have special characteristic nature when a developer assigns value beyond the range of the data type. There will be no compiler error and the value changes according to a cyclic order. This is called cyclic nature. Char, int, long int data types have this property. Further float, double and long double data types do not have this property.

29- Describe the header file and its usage in C programming?

The file containing the definitions and prototypes of the functions being used in the program are called a header file. It is also known as a library file.

Example: The header file contains commands like printf and scanf is from the stdio.h library file.

30- What is an array in C?

An Array is a group of similar types of elements. It has a contiguous memory location. It makes the code optimized, easy to traverse and easy to sort. The size and type of arrays cannot be changed after its declaration.

Arrays are of two types:

  • One-dimensional array: One-dimensional array is an array that stores the elements one after the another.


data_type array_name[size];  
  • Multidimensional array: Multidimensional array is an array that contains more than one array.


data_type array_name[size];  

31- What is the usage of the pointer in C?

  • Accessing array elements: Pointers are used in traversing through an array of integers and strings. The string is an array of characters which is terminated by a null character ‘\0’.
  • Dynamic memory allocation: Pointers are used in allocation and deallocation of memory during the execution of a program.
  • Call by Reference: The pointers are used to pass a reference of a variable to other function.
  • Data Structures like a tree, graph, linked list, etc.: The pointers are used to construct different data structures like tree, graph, linked list, etc.

32- What is a NULL pointer in C?

A pointer that doesn’t refer to any address of value but NULL is known as a NULL pointer. When we assign a ‘0’ value to a pointer of any type, then it becomes a Null pointer.

33- What is a far pointer in C?

A pointer which can access all the 16 segments (whole residence memory) of RAM is known as far pointer. A far pointer is a 32-bit pointer that obtains information outside the memory in a given section.

34- What is a C Token?

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

35- What is Preprocessor?

A Preprocessor Directive is considered as a built-in predefined function or macro that acts as a directive to the compiler and it gets executed before the actual C Program is executed.

36- What is /0 character?

The Symbol mentioned is called a Null Character. It is considered as the terminating character used in strings to notify the end of the string to the compiler.

37- What is the behavioral difference when the header file is included in double-quotes (“”) and angular braces (<>)?

When the Header file is included within double quotes (“ ”), compiler search first in the working directory for the particular header file.

If not found, then it searches the file in the include path. But when the Header file is included within angular braces (<>), the compiler only searches in the working directory for the particular header file.

38- What is a sequential access file?

General programs store data into files and retrieve existing data from files. With the sequential access file, such data are saved in a sequential pattern. When retrieving data from such files each data is read one by one until the required information is found.

39- 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.
  • Static memory is allocated using static keyword.
  • The static memory is implemented using stacks or heap.
  • 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.

40- What is dynamic memory allocation?

  • In case of dynamic memory allocation, memory is allocated at runtime and memory can be increased while executing the program. It is used in the linked list.
  • The malloc() or calloc() function is required to allocate the memory at the runtime.
  • An allocation or deallocation of memory is done at the execution time of a program.
  • No dynamic pointers are required to access the memory.
  • The dynamic memory is implemented using data segments.
  • Less memory space is required to store the variable.

For example :

int *p= malloc(sizeof(int)*10);  

The above example allocates the memory at runtime.

41- What is the main difference between the Compiler and the Interpreter?

Compiler is used in C Language and it translates the complete code into the Machine Code in one shot. On the other hand, Interpreter is used in Java Programming Langauge and other high-end programming languages. It is designed to compile code in line by line fashion.

42- Can I use int datatype to store 32768 value?

No, Integer datatype will support the range between -32768 and 32767. Any value exceeding that will not be stored. We can either use float or long int.

43- Where can we not use &(address operator in C)?

We cannot use & on constants and on a variable which is declared using the register storage class.

44- Differentiate between getch() and getche().

Both the functions are designed to read characters from the keyboard and the only difference is that –

getch(): reads characters from the keyboard but it does not use any buffers. Hence, data is not displayed on the screen.

getche(): reads characters from the keyboard and it uses a buffer. Hence, data is displayed on the screen.

int main()
char ch;
printf("Please enter a character ");
printf("nYour entered character is %c",ch);
printf("nPlease enter another character ");
printf("nYour new character is %c",ch);
return 0;

45- Explain toupper() with an example.

toupper() is a function designed to convert lowercase words/characters into upper case.

int main()
char c;
printf("%c after conversions  %c", c, toupper(c));
printf("%c after conversions  %c", c, toupper(c));

46- What is the method to save data in a stack data structure type?

Data is stored in the Stack data structure type using the First In Last Out (FILO) mechanism. Only top of the stack is accessible at a given instance. Storing mechanism is referred as a PUSH and retrieve is referred to as a POP.

47- What is the significance of C program algorithms?

The algorithm is created first and it contains step by step guidelines on how the solution should be. Also, it contains the steps to consider and the required calculations/operations within the program.

48- Is it possible to use curly brackets ({}) to enclose a single line code in C program?

Yes, it works without any error. Some programmers like to use this to organize the code. But the main purpose of curly brackets is to group several lines of codes.

49- Describe the modifier in C?

Modifier is a prefix to the basic data type which is used to indicate the modification for storage space allocation to a variable.

Example– In a 32-bit processor, storage space for the int data type is 4.When we use it with modifier the storage space change as follows:

  • Long int: Storage space is 8 bit
  • Short int: Storage space is 2 bit

50- What are the modifiers available in C programming language?

There are 5 modifiers available in the C programming language as follows:

  • Short
  • Long
  • Signed
  • Unsigned
  • long long

51- Can I create a customized Head File in C language?

It is possible to create a new header file. Create a file with function prototypes that need to be used in the program. Include the file in the ‘#include’ section in its name.

52- What do you mean by Memory Leak?

Memory Leak can be defined as a situation where programmer allocates dynamic memory to the program but fails to free or delete the used memory after the completion of the code. This is harmful if daemons and servers are included in the program.

53- When should we use the register storage specifier?

We use Register Storage Specifier if a certain variable is used very frequently. This helps the compiler to locate the variable as the variable will be declared in one of the CPU registers.

54- Which statement is efficient and why? x=x+1; or x++; 

x++; is the most efficient statement as it just a single instruction to the compiler while the other is not.

55- Which variable can be used to access Union data members if the Union variable is declared as a pointer variable?

Arrow Operator( -> ) can be used to access the data members of a Union if the Union Variable is declared as a pointer variable.

56- Mention File operations in C Language.

 Basic File Handling Techniques in C, provide the basic functionalities that user can perform against files in the system.

fopen()To Open a File
fclose()To Close a File
fgets()To Read a File
fprint()To Write into a File

57- What is typecasting?

Typecasting is a process of converting one data type into another is known as typecasting. If we want to store the floating type value to an int type, then we will convert the data type into another data type explicitly.


(type_name) expression;

58- Explain the # pragma directive.

The following points explain the Pragma Directive.

  • This is a preprocessor directive that can be used to turn on or off certain features.
  • It is of two types #pragma startup, #pragma exit and pragma warn.
  • #pragma startup allows us to specify functions called upon program startup.
  • The #pragma exit allows us to specify functions called upon program exit.
  • #pragma warn tells the computer to suppress any warning or not.

59- What is indirection?

If you have defined a pointer to a variable or any memory object, there is no direct reference to the value of the variable. This is called the indirect reference. But when we declare a variable, it has a direct reference to the value.

60- What is the explanation for modular programming?

The process of dividing the main program into executable subsection is called module programming. This concept promotes reusability.

Start learning HTMLCSS and JavaScript.

Test your skills with Amazing Quizzes.

Also Read :

Leave a Comment

Your email address will not be published. Required fields are marked *