iGET

C Programming - MCQ Practice Questions

Practice free C Programming multiple-choice questions with detailed answers and explanations. Perfect for competitive exam preparation.

972 questions | 100% Free

Q.161Hard

Consider this code: int *p = malloc(sizeof(int)); int *q = p; free(p); q[0] = 5; // What is the result?

Q.162Hard

What distinguishes a dangling pointer?

Q.163Hard

For a program handling 10^6 integers dynamically, which allocation is most appropriate?

Q.164Hard

What is the typical behavior if malloc() is called in a loop without corresponding free() calls?

Q.165Hard

What is a potential issue when allocating very large contiguous blocks (>10^8 bytes) dynamically?

Q.166Hard

Consider this: char *p = malloc(10); strcpy(p, "Hello World"); What occurs?

Q.167Hard

For implementing a dynamic stack in competitive programming, which memory management approach is best?

Q.168Hard

In a dynamic stack implementation for competitive programming, how should you handle reallocation when the stack becomes full?

Q.169Hard

Which of these represents proper error handling for malloc in competitive programming?

Q.170Hard

For a dynamic hash table with chaining, if collision occurs, the new element should be inserted where?

Q.171Hard

What is the memory overhead when allocating 1000 integers vs 1 integer in a system with malloc metadata?

Q.172Hard

In competitive coding, when implementing dynamic trees, which traversal is most suitable for level-order?

Q.173Hard

Which memory allocation technique provides better locality of reference for accessing array elements?

Q.174Hard

Which statement about #define is TRUE?

Q.175Hard

What is the problem with this macro? #define DOUBLE(x) x*x int result = DOUBLE(2+3);

Q.176Hard

What will be the output? #define MIN(a,b) ((a)<(b)?(a):(b)) int x=5; int y=10; int z = MIN(x++, y++);

Q.177Hard

What is the difference between #if and #ifdef?

Q.178Hard

What preprocessor features should be avoided for safer code?

Q.179Hard

Consider: #define MAX(a,b) ((a)>(b)?(a):(b)) Which advantage does this provide?

Q.180Hard

What will be output? #define PRINT(x) printf(#x " = %d\n", x) PRINT(5+3);