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

Consider a 2D array int matrix[3][3]. If we access matrix as a 1D array, how many total elements can we access?

Q.2Hard

What will be output of the following code? char str[] = "GATE2025"; for(int i=0; str[i]!='\0'; i++) if(i%2==0) printf("%c", str[i]);

Q.3Hard

Consider: int arr[3][4][5]. What is the size of arr[0][0]?

Q.4Hard

Which of the following is true about strcpy(dest, src)?

Q.5Hard

What is the main difference between char arr[] = "Test" and char *ptr = "Test"?

Q.6Hard

If ptr is a pointer to int array and ptr = arr, what does ptr[3] represent?

Q.7Hard

What is the correct way to safely copy strings in modern C?

Q.8Hard

In the declaration int *arr[10], what is arr?

Q.9Hard

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

Q.10Hard

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

Q.11Hard

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

Q.12Hard

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

Q.13Hard

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

Q.14Hard

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

Q.15Hard

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

Q.16Hard

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

Q.17Hard

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

Q.18Hard

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

Q.19Hard

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

Q.20Hard

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