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

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

Q.822Medium

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

Q.823Easy

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

Q.824Medium

Which scenario best demonstrates a memory leak?

Q.825Medium

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

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

Q.827Hard

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

Q.828Medium

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

Q.829Medium

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

Q.830Hard

What distinguishes a dangling pointer?

Q.831Hard

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

Q.832Hard

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

Q.833Easy

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

Q.834Easy

What does free() function do in C?

Q.835Easy

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

Q.836Easy

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

Q.837Medium

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

Q.838Medium

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

Q.839Medium

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

Q.840Medium

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