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

Which statement about free() is correct?

Q.22Medium

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

Q.23Medium

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

Q.24Medium

Which scenario best demonstrates a memory leak?

Q.25Medium

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

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

Q.27Medium

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

Q.28Medium

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

Q.29Medium

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

Q.30Medium

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

Q.31Medium

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

Q.32Medium

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

Q.33Medium

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

Q.34Medium

For a graph with V vertices and E edges stored dynamically, what is typical space complexity?

Q.35Medium

What is the critical issue with this code? int *p = (int*)malloc(sizeof(int)); free(p); p = NULL;

Q.36Medium

In 2024-2025 competitive exams, for storing variable number of test cases (up to 10^5), which approach is optimal?

Q.37Medium

In a competitive programming problem, you need to allocate a 2D array of size 5x5 dynamically. Which approach is most efficient?

Q.38Medium

What is the critical issue with this code snippet? int *ptr = (int*)malloc(10); ptr[11] = 5;

Q.39Medium

Which of the following is a memory leak?

Q.40Medium

In the 2024-2025 competitive exam pattern, a dynamic array needs to grow from 100 to 200 elements. Using realloc(), what should be the concern?