iGET

C Programming - MCQ Practice Questions

C questions in placement tests and university exams are rarely about syntax alone. Most of what you will find here is output prediction, pointer arithmetic, arrays and strings, structures and unions, storage classes, recursion, and file handling. The explanations walk through memory behaviour step by step, which is usually where the confusion sits rather than in the code itself.

972 questions | 100% Free

Q.841Medium

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

Q.842Medium

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

Q.843Hard

What is a potential issue when allocating very large contiguous blocks (>10^8 bytes) dynamically?

Q.844Hard

Consider this: char *p = malloc(10); strcpy(p, "Hello World"); What occurs?

Q.845Hard

For implementing a dynamic stack in competitive programming, which memory management approach is best?

Q.846Easy

Which function in C is used to allocate memory dynamically at runtime?

Q.847Easy

Which header file must be included to use malloc() and free() functions?

Q.848Easy

What happens when malloc() fails to allocate memory?

Q.849Medium

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

Q.850Medium

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

Q.851Medium

Which of the following is a memory leak?

Q.852Medium

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?

Q.853Easy

What is the result of calling free() on a NULL pointer?

Q.854Medium

Which scenario represents a use-after-free error?

Q.855Medium

For storing variable-length strings dynamically in a competitive program, what's the safest approach?

Q.856Medium

What potential issue occurs with this code in a large-scale system?
while(1) { int *arr = malloc(1000000); }

Q.857Medium

In graph algorithms with dynamic adjacency lists, what's the memory requirement for a sparse graph with V vertices and E edges?

Q.858Medium

What is the advantage of dynamic allocation over static allocation in competitive programming?

Q.859Medium

Which function should be used to allocate memory for an array of 50 structures of size 'sizeof(struct Node)' and initialize to zero?

Q.860Medium

What happens when you try to free a pointer that was not allocated by malloc/calloc/realloc?