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

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

Q.822Medium

Which scenario best demonstrates a memory leak?

Q.823Medium

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

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

Q.825Hard

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

Q.826Medium

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

Q.827Medium

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

Q.828Hard

What distinguishes a dangling pointer?

Q.829Hard

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

Q.830Hard

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

Q.831Easy

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

Q.832Easy

What does free() function do in C?

Q.833Easy

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

Q.834Easy

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

Q.835Medium

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

Q.836Medium

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

Q.837Medium

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

Q.838Medium

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

Q.839Medium

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

Q.840Medium

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