iGET

C Programming - MCQ Practice Questions

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

978 questions | 100% Free

Q.401Medium

What is the output of this code? int *p = calloc(3, sizeof(int)); printf("%d %d %d", p[0], p[1], p[2]);

Q.402Medium

Consider reallocating memory: int *p = malloc(10); p = realloc(p, 20);

Q.403Medium

Which allocation method is most suitable for a dynamically growing linked list?

Q.404Medium

How can you safely check if malloc() succeeded?

Q.405Medium

In the context of dynamic memory, what does 'memory fragmentation' refer to?

Q.406Medium

What will happen if you try to allocate extremely large memory? int *p = malloc(INT_MAX);

Q.407Medium

Which best practice prevents memory leaks in complex programs?

Q.408Medium

What does realloc() do if the new size is smaller than the old size?

Q.409Medium

What will be the output of this code? int *p = (int*)malloc(5 * sizeof(int)); printf("%d", sizeof(p));

Q.410Medium

Which statement about free() is correct?

Q.411Medium

In dynamic 2D array creation: int arr = (int)malloc(m * sizeof(int*)); what does the first malloc() allocate?

Q.412Medium

What happens if you use a pointer after calling free() on it (without reallocating)?

Q.413Medium

Which scenario best demonstrates a memory leak?

Q.414Medium

What is the output of this code? int *p = (int*)calloc(3, sizeof(int)); printf("%d %d %d", p[0], p[1], p[2]);

Q.415Medium

If realloc() cannot expand memory at the current location, what does it do?

Q.416Medium

In competitive exams, why is dynamic allocation preferred over static arrays for unknown input sizes?

Q.417Medium

What is the correct way to allocate a dynamic array of struct for 'n' elements? struct Node { int data; char name[20]; };

Q.418Medium

A competitive programmer allocates a 2D array dynamically. What is the correct approach?

Q.419Medium

Consider a program that repeatedly allocates memory in a loop but never frees it. What problem occurs?

Q.420Medium

What happens if you call free() twice on the same pointer?