C Programming Language Interview Questions and Answers

The Basic C programming language interview questions and answers are explained in detail with simple and easy language, which will be useful for fresher’s and experience job seekers and hope you find these C interview Questions and Answers useful.

1. What are the features of C language?

C programming language is middle level language and developed by Dennis Ritchie at Bell Laboratories during 1972. It has the following features: High portability, pointer implementation, simplicity, flexibility and memory managements etc.

2. What are the difference between C and C++?

  • C is procedural programming language whereas C++ is Object Oriented Programming(OOPS) Language
  • C language uses top-down approach and C++ used bottom-up approach
  • C language does not support namespace while C++ support it.
  • In C language, polymorphism is not support and C++ supports polymorphism.
  • Overloading is supported in C++ and C language has not support overloading.

3. What are header files in C?

Header files in C Language contains declaration of functions, macros and other library files with directive #include. Most commonly used header files in C language are #include<stdio.h>, #include<conio.h> etc.

4. What is the purpose of using main() in C?

In C programming language, execution of program start from main() and it is also used to invokes(calls) other functions in the program. It is user-defined function.

5. What is the different between string and character?

Character stores a single value(alphabet) like x,y and z whereas string is used to array(more than 1 character) of character(alphabets) like xyz.

6. What is structure and unions?

Structure are used to group different variable under the same name with different memory allocation(memory address) whereas union also group different variables under same name but it allocate same memory location.

7. Name some header files in C?

Some of most commonly used header files in C programming Language: <stdio.h>, <conio.h>, <math.h>,<string.h> etc.

8. What is pointer?

Pointers are variables which stores the address(memory location) of another variable. Pointers are can be used as reference variable and to access data stored in arrays.

9. What is the use of typedef?

In C programming language, typedef(type definition) is used to create own variable type.

10. What is Syntax Error?

Syntax error may be cause due to incorrectly writing programming code and not following programming syntax efficiently. Syntax errors are found during compilation of program.

11. How Variable are different from constant?

A variables can change it value while constant cannot change it value once it is declared as constant. For example, pi=3.14 or dozen is equal to 12 are constant.

12. What is the difference between Array and Pointer?

  • Array has sequence(contiguous) of pre-located memory location for it elements of similar data types whereas pointer stores address of variables.
  • Pointers use * operator to access memory address and array uses subscript variables.

13. What is Array?

Array is a collection of similar data types. Array is a variable which stores(hold) multiple elements(variables) of same data types.

14. What is dangling pointer?

When a variable is deleted or no longer located(memory freed) in a memory location, but the pointer still points to that memory location(address). Such pointers are called as dangling pointers.

15. What is enumeration?

In C programming, enumeration is used to defined fixed number of constants. Enum values are final and cannot be changed once it values is created. E.g. enum WeekDays{ Mon, Tue, Wed, Thur, Fri, Sat, Sun}

16. What is null pointer?

Null pointer is a special reserved pointer which point nowhere(to nothing) or has value null(typically has value 0).

17. What are Volatile variable?

A volatile variable tell compiler that its value may change at any time e.g. it is used in I/O mapped location.

18. What is union?

Union in C language are almost similar to structure(which group different variable under same name) but the only different is memory allocation, as all the variable(members) are stored in same memory address.

19. What is the use of unions?

Union are useful for saving lots of memory allocation(address) as all the variables are stored in same address.

20. Difference between static memory allocation and dynamic memory allocation?

In static memory allocation, memory allocation is occurs during compile time whereas in dynamic memory allocation is done during runtime.

21. Difference between Arrays and linked list?

Array has contiguous memory location whereas linked list contains nodes(which points to next list). Linked list can be easily grown in size and in arrays it is quite difficult. In arrays, elements cannot be added additionally once there are declared whereas in linked list is can be done easily.

22. What are the uses of pointers?

  • Pointer in C programming language is used for:
  • Dynamic memory allocation
  • Access stored data in arrays
  • Used in call by reference
  • Memory management optimization

23. What is the difference between call by value and call by reference?

In call by value, values of variables are called(send) as a parameter to function whereas in call by reference address of variable is called(send).

24. What is malloc()?

The malloc() function reserves or allocate a bytes of memory(specified or requested memory) from heap. Here malloc() means Memory Allocation.

25. What is calloc()?

calloc() allocates block of memory for array of elements of certain size . calloc is abbreviated for contiguous memory.

26. What is macro?

Macro are identifiers which is piece(statement or fragment) of code. Whenever macro is used (pre-processor see macro) in the program, it is replace by text or string(statement or fragment code).

27. What is the use of sizeof() operator?

The sizeof() operator in C language is used to display the size of data types in bytes.

28. What is getch()?

getch() reads the character without displaying or echoing it. getch() process the character just after pressing key, not letting you to press enter key.

29. What is the different between getch() and getche() functions?

getch () reads the character just after pressing the key without echoing(displaying) while getche() reads and display the character just after pressing any key.

30. Can we create own header files? How?

Yes, we can create our own header files in C language.

Need to write any code which you want to make header file

Now save the above program with sumof.h in bin or include folder

Accessing own header file