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
What does calloc() do that malloc() doesn't?
What is the output of this code? int *p, *q; int x = 5; p = &x; q = p; printf("%d %d", *p, *q);
Which statement correctly declares a pointer to a pointer?
What will be printed? int x = 100, y = 200; int *p = &x; int *q = &y; p = q; printf("%d", *p);
What is the primary disadvantage of using free() without proper checks?
What will be the output? char *str = "Hello"; printf("%c", *(str+1));
What is the output? void func(int *arr) { arr[0] = 100; } int main() { int a[5] = {1,2,3,4,5}; func(a); printf("%d", a[0]); }
Which of the following is valid pointer arithmetic in C?
Which of the following correctly declares a pointer to a function that takes two integers and returns an integer?
What happens when you try to modify a string literal through a pointer? char *str = "Hello"; str[0] = 'J';
Consider the code: int *p = NULL; int *q = malloc(sizeof(int)); free(q); free(q); What is the issue here?
What is the output? int a = 10; int *p = &a; int *q = p; q = NULL; printf("%d", *p);
Which pointer operation is NOT valid in C?
What is the output? int arr[2][3] = {{1,2,3}, {4,5,6}}; int *p = (int*)arr; printf("%d", *(p+4));
Which of the following is correct about pointer assignment? int *p, *q; p = q; // What happens?
What is the output? int x = 5; int *const p = &x; x = 10; printf("%d", *p);
What is the output? int arr[] = {10, 20, 30}; int *p = arr; printf("%d", sizeof(p));
Consider the code: int x = 10; int *p = &x; int q = &p; What is the value of q?
Which operation is NOT allowed on void pointers in C without explicit casting?
What is the difference between NULL and a wild pointer?