C Interview Questions and Answers

How do declare an array?

We can declare an array by specify its data type, name and the number of elements the array holds between square brackets immediately following the array name.

int array_int[10]; 

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.

What is a string? How do you know its length?

In C, a string is a character array which is terminated by a null character (‘’). The null character tells the string functions to end of the string.
The strlen() function can be used to measure the length of a string. It returns the total number of bytes taken by the string and it is not counted the null character in the string.

What is static memory allocation?

Allocated the memory at compile time called static memory allocation.It is fixed and can't be increased at runtime.

What is dynamic memory allocation?

Allocation of memory at the time of execution is called dynamic memory allocation. In C, It is done via using the standard library functions malloc() and calloc().

What functions are used for dynamic memory allocation in C language?

C provides four dynamic memory allocation functions, those are
malloc(), calloc(), realloc() and free()

What are the difference between malloc() and calloc()?

malloc(): The malloc() function takes only one argument and used toallocates single block of requested memory. It has garbage value initially.
calloc(): The calloc() function takes two arguments and used toallocates multiple block of requested memory. It initially initializes all bytes to zero.

Explain realloc()?

The realloc() function can change the size of a memory space allocated by the malloc() ,calloc() and realloc() itself.

The syntax for the realloc() function is
void *realloc(void *block, size_t size);
Here block is the pointer to the start of a piece of memory space previously allocated.
size specifies the total byte number you want to change to.

What free() function do?

The free() function can be release unused allocated memory by the malloc(), calloc(), or realloc() function.

What are enumerated or enum types?

The enumerated data type can be used to declare named integerconstants.Enumerators are defined with the keyword enum.
By default, the first enumname starts with the value of 0 and the value of each name in the
rest of the list increases by one from left to right.


where SUN represent 0 and MON to SAT respectively 1 to 6

we can also assign any integer values to enum names.

What Is a Structure?

Structure is a user-defined data type and collection of heterogeneous data items,that is collection of different variables with their data type.
The data items in a structure are called members of the structure,whereasvthe structure member can be refer via dot operator (.) with structure variable and arrow operator (->) with structure pointer variable.
for ex
structure student as:

struct student {
} student1;

What Is a Union?

union is similar to a structure, except that the data items saved in the union are overlaid in order to share the same memory location. That is, they all share the same starting address.
The allocated size of a union is at least as large as the size of the largest data item in the list of the union members in memory.

Like a structure, you can reference a union’s members by using dot and arrow operator with it variable.

What are the differences between a union and a structure?

The major differences between structure and union are:

(i) In structure every member has its own memory whereas in union its members share the same member space.
(ii) In structure, it is possible to initialize all the members at the same time which is not possible in case of union. 

What is command line arguments?

The arguments that we pass to main() at command prompt are called command line arguments. These arguments are supplied at the time of invoking the program.
The main()function can take arguments as:main(int argc,char *argv[]) { }
The first argument argc is known as argument counter. It represents the number of arguments in the command line.The second argument argv is known as argument vector. It is an array of char type pointers that points to the command line arguments.Sizeof this array will be equal to the value of argc.

What is a preprocessor?

Preprocessor is a directive to the compiler to perform certain things before the actual compilation process begins.

What is the difference between pre increment and post increment operator?

Post-increment (ex: x++) returns a copy of the original value before increment itself. Pre-increment (ex: ++x) returns a copy of the original value plus 1.
int i=0, j, k;
printf("%d %d %d ", i, j, k);

Output :> 2 0 2    

Latest Updates

Indian Politics

______is an institutional mechanism to provide representation to the states of India?

Books and Authors

Which text is not written by Kalidasa?

Indian Constitution

Which Constitutional Amendment introduced Right to Education as a Fundamental Right?

Indian History

Which animal is engraved on Harappan seals?

Indian Politics

Who is known for initiating electoral reforms in India to ensure free and fair elections?

Indian Constitution

The sequence in which the given terms are mentioned in the preamble to the Constitution of India is?

Which of the following parts of the Constitution of India provides fundamental rights ?

Books and Authors

Who among the following is the author of ‘Politics’?

Which one is the text not written by Abul Fazl?

Which King was the author of Ratnawali, Nagananda, Priyadarsika?

Fill in the blank

Fill in the blanks with the most appropriate preposition in the given sentence.
The class begins _______ 7:30 am _____ the morning.

The workers were so skilled that their _____ was quite visible even to a layman.


Choose appropriate article for the given sentence:
______ German is ___ easy language to learn for English speaking students.


What will be the synonym of ‘Eradicate’?

What will be the synonym of the word ‘disaster’?

Pipes and Cistern

Three taps A,B and C can fill a tank in 12, 15 and 20 hours respectively. If A is open all the time and B and C are open for one hour each alternatively, the tank will be full in?

Two pipes A and B can fill a tank in 6 hours and 4 hours respectively. If they are opened on alternate hours and if pipe A s opened first, in how many hours, the tank shall be full?

A large tanker can be filled by two pipes A and B in 60 min and 40 min respectively. How many minutes will it take to fill the tanker from empty state if B is used for first half of the time, and A and B fill it together for the other half?

Latest Job Notifications

Banking Jobs

बैंकिंग कार्मिक चयन संस्थान Institute of Banking Personnel Selection(IBPS) - 7855 पद - 29/07/2022 अंतिम तिथि

SSC Recruitment

कर्मचारी चयन आयोग (एसएससी) Staff Selection Commission (SSC) - 1411 पद - 29/07/2022 अंतिम तिथि

Jobs in Rajasthan

राजस्थान अधीनस्थ और मंत्रिस्तरीय सेवा चयन बोर्ड Rajasthan Subordinate and Ministerial Services Selection Board (RSMSSB) - 5546 पद - 22-Jul-2022 अंतिम तिथि

Railway Recruitment

उत्तर मध्य रेलवे भर्ती प्रकोष्ठ Railway Recruitment Cell(NCR) - 1659 पद - 01/08/2022 अंतिम तिथि

Jobs in West Bengal

इंडियन पोस्ट सर्विस Indian Post Service - 2357 पद - 19/08/2021 अंतिम तिथि - पश्चिम बंगाल पोस्टल सर्कल

Banking Jobs

भारतीय स्टेट बैंक State Bank of India(SBI) - 6100 पद - 26/07/2021 अंतिम तिथि - CRPD/APPR/2021-22/10

SSC Recruitment

कर्मचारी चयन आयोग Staff Selection Commission(SSC) - 25271 पद - 31/08/2021 अंतिम तिथि

Jobs in Madhya Pradesh

राष्ट्रीय स्वास्थ्य मिशन मध्य प्रदेश National Health Mission MP(NRHM) - 5215 पद - 22/06/2021 अंतिम तिथि

Jobs in Punjab

पंजाब स्टेट पावर कॉर्पोरेशन लिमिटेड Punjab State Power Corporation Limited (PSPCL) - 2632 पद - 20/06/2021 अंतिम तिथि

Jobs in Chhattisgarh

स्वास्थ्य सेवा निदेशालय, छत्तीसगढ़ Department of Health & Family Welfare, Chhattisgarh - 267 पद - 26/06/2021 अंतिम तिथि