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.81Hard

In a dynamic 2D array created as: int arr = (int)malloc(rows * sizeof(int*)); What is the next step?

Q.82Hard

What will happen? char arr[5] = "Hello"; printf("%d", strlen(arr));

Q.83Hard

What happens with this code? char *ptr; char str[] = "Programming"; ptr = str; ptr[2] = 'X';

Q.84Hard

What will the following code print? int arr[3] = {10, 20, 30}; int *p = arr; printf("%d %d", *p++, *++p);

Q.85Hard

How should dynamic 1D array of strings be declared for 5 strings of length 20?

Q.86Hard

What is the most efficient way to copy one array to another in C?

Q.87Hard

What is the relationship between pointer arithmetic and array indexing in C?

Q.88Hard

What potential issue exists with this code: char *ptr = "Hello"; ptr[0] = 'h';?

Q.89Hard

For a 3D array int arr[2][3][4], what is arr[1][2][3] equivalent to?

Q.90Hard

In string handling, what is the difference between fgets() and gets()?

Q.91Hard

Which of the following correctly declares a pointer to an array (not array of pointers)?

Q.92Hard

In what scenario would you use memcpy() instead of strcpy()?

Q.93Hard

What does the strspn() function do?

Q.94Hard

What is the difference between *p++ and (*p)++?

Q.95Hard

What does the following code do? int *p = (int*)malloc(sizeof(int)); *p = 5; free(p); p = NULL;

Q.96Hard

Which statement is true about void pointers?

Q.97Hard

What is the output? int x = 50; int *p = &x; int *q = p; q = NULL; printf("%d", *p);

Q.98Hard

In a function that returns a pointer, which of the following is UNSAFE?

Q.99Hard

Consider: int *p = (int *)malloc(5 * sizeof(int)); for(int i=0; i<5; i++) *(p+i) = i*10; Which statement correctly deallocates this memory?

Q.100Hard

A programmer uses a pointer variable but forgets to initialize it before dereferencing. Which type of error will occur?