A list of top 50 frequently asked C programming interview questions and answers are given below.
1) What is C language?
C is a mid level and procedural programming language. More details...
2) Why C is known as a mother language?
C is known as a mother language because most of the compilers, kernals and JVMs are written in C language. More details...
3) Why C is called a mid level programming language?
It supports the feature of both low-level and high level languages that is why it is known as a mid level programming language. More details...
4) Who is the founder of C language?
Dennis Ritchie. More details...
5) When C langauge was developed?
C language was developed in 1972 at bell laboratories of AT&T. More details...
6) What are the features of C language?
The main features of C language are given below:
- Simple
- Portable
- Mid Level
- Structured
- Fast Speed
- Memory Management
- Extensible
7) What is the use of printf() and scanf() functions?
The printf() function is used for output and scanf() function is used for input.
More details...8) What is the difference between local variable and global variable in C?
Local variable: A variable which is declared inside function or block is known as local variable.
Global variable: A variable which is declared outside function or block is known as global variable.
9) What is the use of static variable in C?
A variable which is declared as static is known as static variable. The static variable retains its value between multiple function calls.
10) What is the use of function in C?
A function in C language provides modularity. It can be called many times. It saves code and we can reuse the same code many times. More details...
11) What is the difference between call by value and call by reference in C?
We can pass value to function by one of the two ways: call by value or call by reference. In case of call by value, a copy of value is passed to the function, so original value is not modified. But in case of call by reference, an address of value of passed to the function, so original value is modified. More details...
12) What is recursion in C?
Calling the same function, inside function is known as recursion. For example:
13) What is array in C?
Array is a group of similar types of elements. It has contiguous memory location. It makes the code optimized, easy to traverse and easy to sort. More details...
14) What is 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. More details...
15) What are the usage of pointer in C?
- Accessing array elements
- Dynamic memory allocation
- Call by Reference
- Data Structures like tree, graph, linked list etc.
16) What is NULL pointer in C?
A pointer that doesn't refer to any address of a value but NULL, is known as NULL pointer. For example:
17) What is far pointer in C?
A pointer which can access all the 16 segments (whole residence memory) of RAM is known as far pointer.
18) What is dangling pointer in C?
If a pointer is pointing any memory location but meanwhile another pointer deletes the memory occupied by first pointer while first pointer still points to that memory location, first pointer will be known as dangling pointer. This problem is known as dangling pointer problem.
19) What is pointer to pointer in C?
In case of pointer to pointer concept, one pointer refers to the address of another pointer. More details...
20) 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 array. More details...
21) What is dynamic memory allocation?
In case of dynamic memory allocation, memory is allocated at run time and memory can be increased while executing the program. It is used in linked list. More details...
22) What functions are used for dynamic memory allocation in C language?
- malloc()
- calloc()
- realloc()
- free()
23) What is the difference between malloc() and calloc()?
malloc(): The malloc() function allocates single block of requested memory. It has garbage value initially.
calloc(): The calloc() function allocates multiple block of requested memory. It initially initializes all bytes to zero.
24) What is structure?
Structure is a user-defined data type that allows to store multiple types of data in a single unit. It occupies the sum of memory of all members. More details...
25) What is union?
Like Structure, union is a user-defined data type that allows to store multiple types of data in a single unit. But it doesn't occupies the sum of memory of all members. It occupies the memory of largest member only. More details...
26) What is auto keyword in C?
In C, every local variable of a function is known as automatic (auto) variable. Let's explain with an example:
Here, both 'i' and 'j' variables are automatic variables.
Note: A global variable can't be an automatic variable.
27) What is the purpose of sprintf() function?
It is used to print the formatted output into char array.
28) Can we compile a program without main() function?
Yes, we can compile but it can't be executed.
But, if we use #define, we can compile and run C program without using main() function. For example:
29) What is token?
Token is an identifier. It can be constant, keyword, string literal etc.
30) What is command line argument?
The argument passed to the main() function while executing the program is known as command line argument. For example:
31) What is the acronym for ANSI?
American National Standard Institute.
32) What is the difference between getch() and getche()?
The getch() function reads a single character from keyboard. It doesn't uses any buffer, so entered data is not displayed on the output screen.
The getche() function reads a single character from keyword but data is displayed on the output screen. Press Alt+f5 to see the entered character.
33) What is new line escape sequence?
The new line escape sequence is represented by "\n". It inserts a new line on the output screen.
More details...34) Who is the main contributor in designing the C language after Dennis Ritchie?
Brain Kernighan.
35) What is the difference between near, far and huge pointers?
A virtual address is composed of selector and offset.
A near pointer doesn't have explicit selector whereas far and huge pointers have explicit selector. When you perform pointer arithmetic on far pointer, selector is not modified but in case of huge pointer it can be modified.
These are the non-standard keywords and implementation specific. These are irrelevant in modern platform.
36) What is the maximum length of an identifier?
It is 32 characters ideally but implementation specific.
37) What is typecasting?
Converting one data type into another is known as typecasting. For example:
38) What are the functions to open and close file in C language?
The fopen() function is used to open file whereas fclose() is used to close file.
39) Can we access array using pointer in C language?
Yes, by holding the base address of array into pointer, we can access the array using pointer.
40) What is infinite loop?
A loop running continuously for indefinite number of times is called infinite loop.
Infinite For Loop:
Infinite While Loop:
Infinite Do-While Loop:
41) Write a program to print "hello world" without using semicolon?
There are various ways to do so. Let's see a program to print "hello world" using if.
1 comments:
Nice article . There is good coding example collection visit
Top coding program example
Post a Comment