B.Tech Students: Apply for Live Programming Internship C, C++, Java, Python ,Web page Designing, PHP C Interview Quiz | C Programming Interview Test

C Programming Quiz: Interview Questions

Q1. What is a null pointer in C?C में null pointer क्या है?

Correct: Pointer that points to 0

A null pointer points to address 0 and is used to indicate that the pointer is not assigned any valid memory.

Q2. What is the difference between '++i' and 'i++' in C?'++i' और 'i++' में क्या अंतर है?

Correct: '++i' increments before use; 'i++' increments after use

'++i' increments the value before it's used, 'i++' increments after the current expression is evaluated.

Q3. What does the 'static' keyword mean in C?C में 'static' कीवर्ड का क्या अर्थ है?

Correct: Variable retains value between function calls

Static variables keep their value between multiple function calls and have internal linkage if declared globally.

Q4. What is the size of 'int' typically in C?C में 'int' का आकार सामान्यतः कितना होता है?

Correct: Depends on compiler and architecture

The size of 'int' depends on the system and compiler, usually 4 bytes on modern systems but not guaranteed.

Q5. What is the difference between 'malloc()' and 'calloc()'?'malloc()' और 'calloc()' में क्या अंतर है?

Correct: malloc() allocates memory without initialization; calloc() initializes memory to zero

malloc() allocates uninitialized memory, whereas calloc() allocates and initializes memory to zero.

Q6. What is the output of the following code? int a = 5; printf("%d", a++);निम्नलिखित कोड का आउटपुट क्या होगा? int a = 5; printf("%d", a++);

Correct: 5

a++ returns the current value (5) and then increments a.

Q7. What are dangling pointers?Dangling pointers क्या होते हैं?

Correct: Pointers pointing to freed memory

Dangling pointers point to memory that has been freed/deallocated and accessing them causes undefined behavior.

Q8. How is a structure different from a union in C?C में structure और union में क्या अंतर है?

Correct: Structure allocates separate memory for each member; union shares memory for all members

Structures allocate memory for each member separately, whereas union members share the same memory location.

Q9. What is the purpose of the 'volatile' keyword?'volatile' कीवर्ड का उद्देश्य क्या है?

Correct: Tells compiler variable may change unexpectedly

'volatile' tells the compiler not to optimize the variable as its value may be changed outside program flow (e.g., hardware).

Q10. What happens if you return a local variable's address from a function?अगर आप किसी फंक्शन से लोकल वेरिएबल का पता लौटाते हैं तो क्या होता है?

Correct: Undefined behavior, because local variable goes out of scope

Local variables are destroyed when function ends, returning their address causes undefined behavior.