Interview Questions.

C Programming Interview Questions and Answers


C Programming Interview Questions and Answers

Q1. What are the important thing features in C programming language?


Portability: Platform impartial language.

Modularity: Possibility to interrupt down large applications into small modules.

Flexibility: The opportunity to a programmer to govern the language.

Speed: C comes with aid for machine programming and for this reason it is compiling and executes with excessive speed while comparing with other high-degree languages.

Extensibility: Possibility to feature new features via the programmer.

Q2. What are the fundamental statistics kinds related to C?


Int: Represent range (integer)

Float: Number with a fraction component.

Double: Double-precision floating point price

Char: Single man or woman

Void: Special reason kind with none fee.

Q3. What are header files and what are its makes use of in C programming?

Ans: Header documents also are referred to as library files. They include  important matters: the definitions and prototypes of functions being used in a application. Simply placed, commands that you use in C programming are truly functions which might be defined from within each header files. Each header file carries a hard and fast of features.

For instance:  "stdio.H" is a header document that incorporates definition and prototypes of instructions like printf and scanf.

Q4. What are reserved words?

Ans: Reserved words are words that are a part of the same old C language library. This method that reserved phrases have special which means and consequently can not be used for functions apart from what it's miles at first supposed for. Examples of reserved phrases are int, void, and return.

Q5. What are the general description for loop statement and available loop kinds in C?

Ans: A statement that allows executing declaration or organization of statements in repeated manner is described as a loop. Following diagram explains

Q6. Following diagram explains a wellknown shape of a loop.

Loop statement

There are four varieties of a loop statement in C.

While loop

For Loop

Do…While Loop

Nested Loop

Q7. Is that possible to shop 32768 in an int data kind variable?

Ans: Int statistics type only capable of storing values among – 32768 to 32767.To save 32768 a modifier wishes to apply with int information type. Long Int can use and additionally if there's no any bad values unsigned int is likewise viable to use.

Q8. What are special storage class specifiers in C?

Ans: auto, register, static, extern.

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

Ans: Scope of a variable is the part of this system in which the variable may additionally without delay be accessible. In C, all identifiers are lexically (or statically) scoped.

Q10. When is the void key-word utilized in a function?

Ans: When maintaining capabilities, you'll decide whether that feature could be returning a price or no longer. If that feature will now not go back a price, along with whilst the motive of a feature is to display some outputs on the display, then void is to be located at the leftmost a part of the characteristic header. When a return price is predicted after the feature execution, the records type of the go back fee is placed rather than void.

Q11. What are connected listing?

Ans: A related listing is composed of nodes which can be connected with any other. In C programming, related lists are created using suggestions. Using linked lists is one efficient manner of utilising reminiscence for garage.

HubSpot Video

Q12. What is NULL pointer? 

Ans: NULL is used to suggest that the pointer doesn’t factor to a legitimate location. Ideally, we need to initialize hints as NULL if we don’t understand their cost on the time of assertion. Also, we ought to make a pointer NULL while memory pointed by means of it's miles deallocated inside the middle of a software.

Q13. What are binary trees?

Ans: Binary timber are genuinely an extension of the concept of related lists. A binary tree has  guidelines, a left one and a right one. Each aspect can in addition department to form additional nodes, which each node having  recommendations as properly.

Q14. How a poor integer is stored?

Ans: Get the two’s praise of the identical tremendous integer. Eg: 1011 (-5)

Step-1: One’s praise of 5 : 1010

Step-2: Add 1 to above, giving 1011, that is -5

Q15. Can a application be compiled without predominant() feature?

Ans: Yes, it may be but can not be finished, because the execution calls for major() characteristic definition.

Q16. What is a nested shape?

Ans: A shape containing an element of some other structure as its member is referred so.

Q17. What is a token?

Ans: A C application consists of numerous tokens and a token is either a key-word, an identifier, a constant, a string literal, or a image.

Q18. What is keyword auto for?

Ans: By default every local variable of the function is automated (auto). In the under feature each the variables ‘i’ and ‘j’ are automated variables.

Void f() 

   int i;

   automobile int j;

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

Q19. What are the exceptional approaches of passing parameters to the capabilities? Which to use when?


Call by using price: We send best values to the characteristic as parameters. We pick this if we do not need the actual parameters to be modified with formal parameters but just used.

Call via reference: We send address of the real parameters in place of values. We choose this if we do want the actual parameters to be changed with formal parameters.

Q20. What is typecasting?

Ans: Typecasting is a way to transform a variable/constant from one kind to another kind.

Q21. How can we determine whether or not a report is successfully opened or not the use of fopen() feature?

Ans: On failure fopen() returns NULL, in any other case opened correctly.

Q22. S++ or S = S+1, which may be encouraged to increment the value through 1 and why?

Ans: S++, as it is unmarried gadget guidance (INC) internally.

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

Ans: Both allocates memory from heap place/dynamic reminiscence. By default calloc fills the allotted memory with zero’s.

Q24. What is lvalue and rvalue?

Ans: The expression appearing on proper aspect of the assignment operator is referred to as as rvalue. Rvalue is assigned to lvalue, which seems on left facet of the project operator. The lvalue have to designate to a variable no longer a consistent.

Q25. Explain modular programming.

Ans: Dividing this system in to sub packages (modules/feature) to gain the given venture is modular technique. More prevalent capabilities definition gives the capacity to re-use the functions, such as integrated library features.

Q26. Where the deal with of operator (&) cannot be used?

Ans: It can not be used on constants. It can not be used on variable that are declared the use of sign up storage magnificence.

Q27. What is the overall form of feature in C?

Ans: Function definition in C carries 4 most important sections:

Return Type: Data form of the return fee of the characteristic.

Function Name: The name of the feature and it is vital to have a significant call that describes the pastime of the function.

Parameters: The input values for the characteristic that need to apply perform the specified movement.

Function Body: Collection of statement that needs to carry out the required movement.

Q28.  What is the difference among functions abs() and fabs()?

Ans: These 2 features essentially carry out the same motion, that's to get the absolute value of the given value. Abs() is used for integer values, even as fabs() is used for floating type numbers. Also, the prototype for abs() is below , at the same time as fabs() is beneath .

Q29.  What is the difference among textual content files and binary files?

Ans: Text files include information that could easily be understood by people. It includes letters, numbers and other characters. On the alternative hand, binary files contain 1's and 0's that only computers can interpret.

Q30. What is dynamic records shape?

Ans: Dynamic statistics shape presents a means for storing information more efficiently into reminiscence. Using dynamic memory allocation, your application will get admission to reminiscence areas as needed. This is in comparison to static records structure, wherein the programmer has to suggest a restore wide variety of memory area for use in the software.

Q31. What is the use of a ' man or woman?

Ans: It is referred to as a terminating null man or woman, and is used typically to show the cease of a string price.

Q32.  What is the difference between the = image and == image?

Ans: The = symbol is often utilized in mathematical operations. It is used to assign a fee to a given variable. On the opposite hand, the == symbol, additionally known as identical to or equal to, is a relational operator this is used to compare  values.

Q33. What are local static variables? What is their use?

Ans: A neighborhood static variable is a variable whose lifetime doesn’t stop with a characteristic name wherein it's far declared. It extends for the life of entire application. All calls to the function percentage the equal reproduction of local static variables. Static variables may be used to count the variety of instances a feature is called. Also, static variables get the default value as zero. For instance, the subsequent application prints “0 1”

#consist of <stdio.H>

void amusing()

     // static variables get the default price as zero.

     Static int x;

     printf ( "%d " , x);

     x = x + 1;


int main()



     go back 0;

// Output: zero 1

Q34. What are static capabilities? What is their use?

Ans: In C, functions are worldwide via default. The “static” keyword earlier than a function call makes it static. Unlike international features in C, get entry to to static functions is constrained to the document wherein they're declared. Therefore, while we need to restriction get admission to to features, we cause them to static. Another reason for making capabilities static can be reuse of the equal feature call in other documents.

Q35. What is the difference among statement and definition of a variable/characteristic?

Ans: Declaration of a variable/characteristic in reality broadcasts that the variable/feature exists somewhere inside the software however the memory is not allocated for them. But the announcement of a variable/function serves an critical position. And this is the type of the variable/function. Therefore, when a variable is said, this system is aware of the facts type of that variable. In case of function announcement, the program knows what are the arguments to that features, their records types, the order of arguments and the return form of the characteristic. So that’s all about statement. Coming to the definition, while we outline a variable/function, other than the role of statement, it also allocates memory for that variable/function. Therefore, we are able to think of definition as a tremendous set of declaration. (or declaration as a subset of definition). From this explanation, it have to be apparent that a variable/function may be declared any range of instances however it is able to be defined handiest once. (Remember the simple principle that you can’t have two locations of the same variable/function).

// This is simplest announcement. Y isn't allocated memory by means of this assertion

extern int y;

// This is both declaration and definition, memory to x is allocated by using this announcement.

  Int x;

Q36. When should we use guidelines variable in a C program?


 To get cope with of a pointer variable

 For reaching bypass by reference in C: Pointers permit specific capabilities to share and adjust their    local variables.

 To bypass big systems so that complete copy of the shape may be averted.

 To put into effect “connected” information structures like related lists and binary timber.

Q37. What is Dangling pointer?

Ans: Dangling Pointer is a pointer that doesn’t point to a legitimate reminiscence location. Dangling tips rise up whilst an item is deleted or deallocated, without editing the value of the pointer, so that the pointer nonetheless points to the memory place of the deallocated memory. Following are examples.


int *ptr = ( int *) malloc ( sizeof ( int ));



Unfastened (ptr); 


// ptr is a dangling pointer now and operations like following are invalid

*ptr = 10;   // or printf("%d", *ptr);


int *ptr = NULL

    int x  = 10;

    ptr = &x;

// x goes out of scope and memory allocated to x is unfastened now.

// So ptr is a hanging pointer now

Q38.  What are the methods to a null pointer can use in C programming language?

Ans: Null tips are viable to use in three methods.

As an blunders cost.

As a sentinel cost.

To terminate indirection in the recursive statistics shape.

Q39. How will you print “Hello World” without semicolon?


int foremost( void )

     if ( printf ( "Hello World" )) ;


Q40.  Write a loop assertion in order to show the subsequent output:







for (a=1; a<=five; i++) 

for (b=1; b<=a; b++)




Q41. What is a stack?

Ans: A stack is one form of a information structure. Data is stored in stacks the use of the FILO (First In Last Out) method. At any specific example, simplest the pinnacle of the stack is accessible, which means that that with a purpose to retrieve statistics this is stored in the stack, the ones at the upper element have to be extracted first. Storing records in a stack is also referred to as a PUSH, while records retrieval is known as a POP.

Q42.  What is a sequential access file?

Ans: When writing programs in an effort to shop and retrieve records in a report, it's far possible to designate that document into extraordinary bureaucracy. A sequential get entry to document is such that statistics are saved in sequential order: one statistics is located into the record after some other. To access a specific data within the sequential access report, information has to be examine one data at a time, until the proper one is reached.

Q43. What are feedback and the way do you insert it in a C software?

Ans: Comments are a tremendous way to position some comments or description in a application. It can serves as a reminder on what the program is all approximately, or an outline on why a positive code or characteristic became positioned there in the first region. Comments start with /* and ended through */ characters. Comments can be a unmarried line, or can even span numerous traces. It may be positioned anywhere inside the software.

Q44.  What is debugging?

Ans: Debugging is the system of figuring out errors inside a application. During application compilation, mistakes which might be discovered will stop the program from executing completely. At this nation, the programmer could check out the feasible quantities wherein the mistake came about. Debugging ensures the removal of mistakes, and plays an vital role in ensuring that the expected software output is met.

Q45. What does the && operator do in a software code?

Ans: The && is also called AND operator. When the usage of this operator, all situations unique should be TRUE before the subsequent motion may be carried out. If you've got 10 conditions and all but 1 fails to evaluate as TRUE, the complete condition announcement is already evaluated as FALSE.