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 is the correct way to declare a 1D array of 10 integers in C?
What will be the output of strlen("Hello") in C?
Which of the following is NOT a valid string initialization?
What does the following code do? strcpy(dest, src);
Consider a 2D array declared as: int matrix[3][4]. How many elements does it have?
What will be the output of the following code? char str[] = "Code"; printf("%c", str[2]);
What is the difference between char str[] = "Test" and char *str = "Test"?
Which function is used to reverse a string in C library?
What is the output of the following code? int arr[] = {10, 20, 30}; printf("%d", sizeof(arr)/sizeof(arr[0]));
What will be printed by: printf("%s", "Hello\0World");?
Consider: int *ptr = arr; where arr is an array. What does ptr[2] represent?
What will the following code output? char str[20]; strcpy(str, "Competitive"); strcat(str, " Exam"); printf("%s", str);
What is the time complexity of searching for an element in an unsorted array of size n?
What will be the output of this code? int arr[5]; for(int i=0; i<5; i++) arr[i] = i*i; printf("%d %d %d", arr[1], arr[2], arr[4]);
Consider a 2D array int matrix[3][3]. If we access matrix as a 1D array, how many total elements can we access?
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]);
If an integer array arr[10] is declared globally in C, what will be the initial values of its elements?
In C, a string is internally represented as:
How much memory is allocated for char name[50] declaration?
What is the time complexity of accessing an element at index 5 in an array?