C Interview Questions Part 4

What is the role of the algorithm in C programming? Elaborate that role.

In order to get the solution to any problem, we have to create the algorithm in order to get step by step solutions. It basically gives the ides of the starting and ending of any program, so it gives a kind of blueprint. It also tells about the computation of the process in a program.

How can you apply comments in C program? Explain in detail.

Comments are basically used to give feedback or remarks in a program. All such comments are used to get instant information regarding the program that the user is using. These comments have no limit as it can be of one line and it may be of several lines and we can place these lines in any place of the program.

What is the exact meaning of debugging in C programming?

Debugging means the process that helps in allocating the errors in the programming. It may stop the process of execution. To solve this process of execution, debugging will identify those errors and remove those errors and complications. So it plays a very important role in the execution process of C programming. So it plays a very important role in the execution process of C programming.

C Interview Questions

What are the different control structures that is followed in the C programming?

” In C programming we usually follow three types of control structures and that are sequence, selection and repetition.

Sequence: this control structure follows the path that runs from a top to bottom in the process of execution of a program and this flow is in sequence.
Selection: In this, the codes are executed based on the conditions of evaluation as true or false.
Repetition: In this, the program statement will follow the steps of repetition. The other name of repetition is called a loop structure.”

What are the functions of reserve words in C programming? Elaborate on them.

Standard C language library has certain words stored in it all such words are called reserve words. All such words are unique and have a different meaning so they cannot be used for any other kind of purpose rather than its original purpose. Some of the examples are void and return etc.

Is C language is a middle-level language? If yes then why is it so?

Yes C language is known to be a middle-level language. This is because it has a unique and interesting feature that makes it act like a higher-level language. But at the same time, it facilitates to use low-level methods in interacting with hardware. It also supports the use of the English type of words in its functioning. All such feature makes it to act as high-level language. Moreover, it has a unique feature of storing the memory structure.

Advance C Interview Questions

What is the role of structure types in C programming?

Major role played by structure types in C programming is to store the records. These records are stored according to their field types. This helps us to easily locate the record at the time of urgent search because we will find all the records in a particular field folder. This helps to save time and money.

Random file access in C programming plays a very important part. Why? list some of its merits.

“We all know that in every computer we store a large amount of significant information and every time we take a lot of time in finding the key content from the large database. Still, this random access file helps in solving this problem.

It helps to find the key data quicker from a large database.
It helps indirectly shifting to target address when there are a lot of addresses in the programming.”

What is the general form that is supported by C programming? Explain its concept in detail.

It commences its process with the preprocessor directives. These directives perform a lot of function like it responsible for specifying the header files and it also tells about the constants to be used in the C programming process. The main function of this programming follows this whole process and that is the heading function. This function performs the variable declaration and the most important program statements.

C Interview Questions

What is the use of modulus operation in C programming?

“Modulus operator in C programming is an important operator in this programming because this modulus operation tells the division operation in the programming function. It basically shows the remainder value left after the division between two numbers. It is represented with the symbol of (%).

For example:

20 % 3 = 2, this will be expressed as, when we divided 20 by 3 we are left with the remainder of 2.
11 % 2 =1, this means that when we divided 11 by 2 we get the remainder of 1.”

What do you mean by nested loop in C programming?

When the one loop gets into the other loop and starts running that loop is called nested loop. The outer loop will specifies the number of times the inner loop will perform its function and every time the first loop performs its tasks.

Elaborate the process by which we can apply quote character (and) in output screen in C programming?

We all know that applying quote character is the part of printf statement an in order to apply this character in output screen, you can use the format of specifiers/ ‘ this is for a single quote and /” for a double quote.

Advance C Interview Questions

List the difference between the source and object code.

“Source code: Source codes usually get a command from the programmer and these codes are responsible for instructing the computer regarding what to perform? With extension .C we can save this code in C programming.
Object code: With the extension. OBJ, we can save the object code in C programming. This is the major difference between the two codes.”

What do you mean by increments and decrement statements in C programming and how we can construct that increment and decrement statements?

“There are basically two types of statements, increment and decrement that are supported by C. There are basically two ways by which we can apply both the statements in C programming. The first one uses the increment operator ( ++ ) and the other is decrement operator ( — ).

For example, if we use ( x ++ ), this means to command increment the value of x with a rate of 1.”

What is the utilization of #undef preprocessor?

As per the C programming language, the #undef directive’s main aim is that it acts as a guide to the preprocessor to get rid of all the definitions for the particular macro. If a macro is non-specific, and #ifdef directive on that specified macro will show the result as false.

C Interview Questions

What are the distinct ways of passing parameters to the function and state along with which is to be used when?

“There are primarily two ways of passing parameters to the function which are listed as follows:

Call by Reference- In this technique, the address of the actual parameter is sent instead of the values. It is chosen in the case when the user doesn’t want the actual parameter to be altered with the formal parameter.
Call by Value- In this technique, we only send values to the functions as the parameters. It is chosen if the user wants the actual parameter to be altered with the formal parameter but just to be used.”

What can be understood from the null pointer and a dangling pointer?

There is a considerable difference that can be noticed in the null and the dangling pointer. The null pointer does not specifically point to anything. That is, it points to nothing. Whereas the dangling pointer is the one who initially holds a valid address, but later on, that valid address gets discharged.

Tell the difference between getch() and getche() functions.

Both getch() and getche() functions are used for reading a single character from the keyboard. The difference between the two, however, lies in terms of displaying the output. The getche() function displays the data, the entered character, on the output screen while the getch() function doesn’t. Use Alt+F5 to see the entered character.

Advance C Interview Questions

Explain the auto keyword in C.

Auto is the default storage class of all the variables declared inside a code block or function. Hence, local variables can also be referred to as automatic or auto variables. If no value is stored in an auto variable, then it gets a garbage value. Auto variables are called so because these variables allocate and deallocate memory upon entering and exiting the code block or function in which they are declared, respectively. Typically, there is no need to mention the auto keyword explicitly.

What is a far pointer in C?

“A far pointer is a 32-bit pointer capable of accessing all the 16 segments, i.e., the whole residence memory of RAM. It can access information outside the computer memory in a given segment. To use the far pointer, it is required to:

Allocate the sector register to store data address in the segment, and
Store another sector register within the most recent sector”

Explain recursion in C.

“Recursion is the process when a function calls itself, directly or indirectly. Such a function is called a recursive function. There are two phases involved with a recursive function:

Winding phase – It starts when the recursive function calls itself and ends once the condition is reached.
Unwinding phase – Starts when the condition is reached, i.e., when the winding phase ends, and ends when the control returns to the original call.”

C Interview Questions

What is a static variable? Why do we need it?

“A variable whose value is fixed and can’t be changed during program execution, i.e., it retains the stored value between multiple function calls, is called a static variable. The keyword static represents a static variable. A static variable is initially initialized to 0. When the value is updated, it gets assigned to the static variable. It is initialized only once in the memory heap. We use a static variable to:

Reduce memory consumption
Sharing a common value across all functions”

Compare local variables and global variables.

“Following are the various differences between the local and global variables:

  1. Declaration
    Local variables are declared inside a function, while global variables are the variables declared outside the functions.
  2. Life
    The life of a local variable is tied with the function block where it is declared. The variable is destroyed when the function exits. Global variables remain for the entire lifetime of the program.
  3. Scope
    The scope of a local variable is confined to the function or code block where it is declared. Global variables have global scope, i.e., they are available throughout the program.
  4. Storage
    Unless specified explicitly, local variables are stored in a stack. The compiler itself decides the storage for a global variable.”

What do you understand by the C preprocessor?

The C compiler automatically uses the C preprocessor for transforming the program, i.e., performing certain things before the actual compilation starts. The C preprocessor is a macro processor because it enables defining brief abbreviations for longer constructs, called macros.

Advance C Interview Questions

Explain tokens in C

“Tokens are the smallest, indivisible units of a C program with distinct meanings. Following are the various types of tokens in C:

Constants – Fixed values that can’t be changed during the program execution.
Identifiers – This refers to the name of the functions, variables, arrays, structures, etc.
Keywords/Reserved Names – Predefined words with special meanings that can’t be used as variable names.
Operators – Symbols that tell the C compiler to perform specific logical, mathematical, or relational operations.
Special Characters – All characters excluding the alphabets and digits are special characters.”

What do you understand by modular programming?

Modular approach to programming involves dividing an entire program into independent, interchangeable sub-programs, i.e., functions and modules for accomplishing the desired functionality. Each of the functions or modules involved in modular programming has everything required to execute a single aspect of the entire program’s desired functionality.

Please explain a self-referential structure.

A self-referential structure contains the same structure pointer variable as its element. In other words, it is a data structure in which the pointer points to the structure of the same data type. A self-referential structure is used in Graphs, Heaps, Linked Lists, Trees, et cetera.

C Interview Questions

How will you resolve the scope of a global symbol?

We can use the extern storage specifier for resolving the scope of a global symbol. The extern keyword is used for extending the visibility or scope of variables and functions. As C functions are visible throughout the program by default, its use with function declaration or definition is not required.

Is #include “stdio.h” correct? What’s the difference between using < > and ” ” for including the header file?

” Yes, #include “”stdio.h”” is correct. The difference between using angle brackets (<>) and double quotes (“” “”) for including a header file is the way in which the compiler searches for the particular header file.

When we use angular brackets, the compiler searches for the header file only within the built-in include path. When, however, double quotes are used, the compiler searches for the header file first in the current working directory, and then in the built-in include path when not found in the current working directory.”

How is pass by value different from a pass by reference?

Pass by value and pass by reference are also called call by value and call by reference, respectively. In the call by value, values are send/passed to the function as parameters. Pass by value is used when there is a requirement of not modifying the actual parameters. Address pertaining to the actual parameters are send/passed to the function in the call by reference. Pass by reference is used when there is a need for modifying the actual parameters. Changes made to the arguments in the called function are not reflected in the calling function in a pass by value. Opposite to this, changes made to the arguments in the called function are reflected in the calling function in a pass by reference.

Advance C Interview Questions

What are the important differences between a structure and a union in C?

“Following are the three important differences between a structure and a union in the C programming language:

For the same data type, a structure requires more memory than a union.
Modifying the value of a member of a structure doesn’t affect other members. Doing the same in a union, however, results in affecting all the members of the union.
While only one element can be accessed at a time in the union, it is possible to access all elements of a structure simultaneously.”

Compare arrays with pointers in the C programming language?

“Following are the various differences between arrays and pointers in C:

Definition – An array is a form of data structure that stores multiple, homogeneous elements at contiguous memory locations. However, a pointer is a variable that stores or points to the memory address of some other variable.
Initialization – It is possible to initialize arrays at the definition. Pointers, however, can’t be initialized at the definition.
Size – While a pointer can store the address of only a single variable, an array is capable of storing multiple elements. The array size determines the total number of elements stored by arrays.”

What do you understand by a pointer on a pointer in C?

 A pointer on a pointer is a pointer containing the address of some other pointer. It is a form of multiple indirections. The first pointer contains the address of the second pointer, which points to the location of the actual value.

C Interview Questions

Explain the role of protected access specifier?

The privacy of a protected keyword lies somewhere between the keywords private and public . If a class is marked as protected, it can be accessed by its member functions, classes derived with public or protected access, privately derived classes and friends of the class that declared these members.

Explain what do you understand by while(0) and while(1)?

while(0) means that the looping conditions will always be false, i.e., the code inside the while loop will not be executed. On the opposite, while(1) is an infinite loop. It runs continuously until coming across a break statement mentioned explicitly.

 Can you explain memory leak in C? Why should it be addressed?

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.

Advance C Interview Questions

Please compare static memory allocation with dynamic memory allocation?

” Following are the important differences between static and dynamic modes of memory allocation:

Memory increase:
In dynamic memory allocation, memory can be increased while executing the program. However, this is not the case with the static memory allocation where the option of increasing memory during program execution is not available.

Memory requirement
Static memory allocation needs more memory space compared to dynamic memory allocation.

Used in
Arrays use static memory allocation while linked lists use dynamic memory allocation.

When does it happen?
Static memory allocation takes place at compile-time, while dynamic memory allocation happens at runtime.”

 How are global variables different from static variables?

Global variables are variables with global scope, i.e., they are accessible throughout the program, unless shadowed. These variables are defined outside a function or code block. Static variables are variables allocated statically, i.e., their value can’t be changed. It is fixed for the entire run of a program. They can be defined outside as well as inside functions. Moreover, they can be accessed from anywhere inside the program.

Enumerate the basic data types in C?

There are 5 basic data types in C:

int – Stores an integer number
float – Stores a decimal number
double – Stores a decimal number with the highest precision
char – Stores a single character
void – Stores no value”

C Interview Questions

What is the objective of the main () function in C?

The main () function in C language to the inlet to the C program. It is the entry point where the process of execution of the program starts. When the C program’s execution initiates, the control of the program is directed towards the main () function. It is mandatory that every C language program has a main () function. Although it is the function that indicates the programming process, it is not the first function to be executed.

What are some of the limitations of C language?

“As everything has a finite potential, so the C language stands in no exception. The following are some of the drawbacks of C languages:

Concept of OOPs: C language prohibits the concept of OOPs as it is based on the procedural approach. (Inheritance, Polymorphism, Encapsulation, Abstraction, Data Hiding).
Run Time Checking: C language does not do the running checking which means that errors are not detected after every line of coding, but only once the complete coding is done making it inconvenient to correct the bugs
Concept of the Namespace: C language does not exhibit Namespace’s property, so there cannot be two variables with the same name in the C language program.
Lack of Exception Handling: The language doesn’t exhibit the important feature of exception handling. The feature of exception handling doesn’t allow the user to detect the errors and bugs while compiling the code.
Insufficient Level for Abstraction: C language doesn’t have a very wide data handling capacity, which poses a threat to the security of the language.”

What are the advantages of using C language over other programming languages?

“C language has the edge over the other programming language, which certainly makes it “The mother of programming language.” Some of the benefits of using C language are stated below:

Middle – Level Language: As the C language is in the midway of a high-level language and low-level language, it brings together the features of both of them. So this distinctive feature of the language makes it possible to be used for low as well as high-level programming.

Structured Level Language: C language is a structured programming language that allows a complex program to be divided into simpler programs called the functions. Thus making it quite a user friendly.
Case Sensitive Language: It is a case sensitive language due to which the lower and the upper case letters are treated differently.
Portable Language: C language is a highly flexible language that enables it to be used for scripting system applications, which makes it a part of many well known operating systems.
Powerful and Efficient Language: It is a user-friendly language and can effectively operate on games, graphics, enterprise applications, applications that need some calculations, etc.”

Advance C Interview Questions

Why is the C language known as “The mother of programming languages”?

The C language is commonly called the “The mother of programming languages” as it is the language that forms the bases of programming. It is a time-honored language and has been widely used to develop some of the most significant compilers and kernels. C language is as old as the hills, and most of the modern languages are nothing but an adaptation from the C languages.

What do you know about the C language, and who invented it and when?

The C language is one of the most commonly used computer programming languages. The language is used by giving step by step instructions, which makes it a procedural language. It is a widely used language that helps carry out systematic programming, lexical variable scope, and recurrent. C language, which is among the most popular languages, had its origin in the early 1970s in America. American computer scientist Dennis M. Ritchie developed it at Bell Laboratories. Since then, it has served humankind in the best possible manner and has helped in developing several system applications.

Please explain a header file in C? What will happen if we include a header file twice in a C program?

“Header files store the definitions and set of rules governing the C programming language’s different built-in functions. For instance, the printf() and scanf() functions are defined in the stdio.h header file.

Every header file contains a set of predefined functions, meant to make programming in C simpler. You need to include the specific header file in your C program to be able to use the functions defined in it. For example, you can’t use print(), and scanf() functions without including the stdio.h header file.

When a header file is included twice in a C program, the second one gets ignored. In actual, the #, called the include guard, preceding a header file ensures that it is included only once during the compilation process.”

C Interview Questions

List some of the most important features of the C programming language.

” C supports a plethora of great features. Most important among them are:

Extensibility – Capable of adopting new features.
Fast – Support for system programming allows faster compilation and execution than popular high-level languages like Java and Python.
Memory Management – Comes with built-in memory management for saving memory and optimizing memory use.
Middle-Level Programming Language – Binds the gap between a machine-level language and a high-level language. It can be used for system programming as well as application programming.
Platform independence/Portability – A C program written for one machine can run on other machines with little to no modifications.
Simplicity – Follows the structured approach. Facilitates breaking down a big, complex program into smaller, independent, and easy-to-manage modules (sub-programs).”

What is the use of a static variable in C?

“Following are the uses of a static variable:

A variable which is declared as static is known as a static variable. The static variable retains its value between multiple function calls.
Static variables are used because the scope of the static variable is available in the entire program. So, we can access a static variable anywhere in the program.
The static variable is initially initialized to zero. If we update the value of a variable, then the updated value is assigned.
The static variable is used as a common value which is shared by all the methods.
The static variable is initialized only once in the memory heap to reduce the memory usage.”

What is the use of the function 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.”

C Interview Questions

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:

Winding phase
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


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″

What is a pointer in C?

“A pointer is a variable that refers to the address of a value. It makes the code optimized and makes the performance fast. Whenever a variable is declared inside a program, then the system allocates some memory to a variable. The memory contains some address number. The variables that hold this address number is known as the pointer variable.

For example:

Data_type *p;
The above syntax tells that p is a pointer variable that holds the address number of a given data type value.

Example of pointer


int main()
int *p; //pointer of type integer.
int a=5;
printf(“”Address value of ‘a’ variable is %u””,p);
return 0;

Address value of ‘a’ variable is 428781252″

C Part 1C Part 2C Part 3
Back to top