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.41Medium

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

Q.42Easy

How much memory in bytes does calloc(10, 4) allocate?

Q.43Medium

Which scenario best demonstrates a memory leak?

Q.44Medium

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.45Medium

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

Q.46Hard

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

Q.47Medium

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

Q.48Medium

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

Q.49Hard

What distinguishes a dangling pointer?

Q.50Hard

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

Q.51Hard

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

Q.52Easy

Which header file must be included to use dynamic memory allocation functions in C?

Q.53Easy

What does free() function do in C?

Q.54Easy

What is the primary difference between malloc() and calloc()?

Q.55Easy

Which of the following correctly allocates memory for an array of 5 integers and initializes to zero?

Q.56Medium

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

Q.57Medium

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

Q.58Medium

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

Q.59Medium

In a competitive programming scenario, you need to store strings dynamically. What is safe practice?

Q.60Medium

A program uses realloc() to expand an array from 100 to 200 elements. The old address is p. After realloc():?