Explore topic-wise MCQs in C Program.

This section includes 40 Mcqs, each offering curated multiple-choice questions to sharpen your C Program knowledge and support exam preparation. Choose a topic below to get started.

1.

The function sprintf() works like printf(), but operates on ..........

A. ata file
B. tderr
C. tring
D. tdin
E. o such function in 'C'.
Answer» D. tdin
2.

What will be the correct output of the following program?#includevoid main(){char str[] = "C EXAMINATION", rev[17];int i = strlen(str), j=0;for( ; i>=0; rev[j++] = str[i--])rev[j] =str[j] ;puts(rev);}

A. OITANIMAXE C
B. OITANIMAXE
C.
D. o output at all.
Answer» E.
3.

What will be the output of the program ?#include#includevoid main(){char str1[20] = "Hello", str2[20] = " World";printf("%s", strcpy(str2, strcat(str1, str2)));}

A. ello World
B. orld
C. orldHello
D. ello
E. one of these
Answer» B. orld
4.

What will be the output of the program ?#include#includevoid main(){char str[] = "Exam\0Veda";printf("%s", str);}

A. xam
B. xam Veda
C. xam\0Veda
D. eda
E. one of these
Answer» B. xam Veda
5.

What will be the output of the following program?void main(){char str1[] = "abcd";char str2[] = "abcd";if(str1==str2)printf("Equal");elseprintf("Unequal");}

A. qual
B. nequal
C. rror
D. one of these.
Answer» C. rror
6.

What will be the output of the program if the array begins at 65472 and each integer occupies 2 bytes?#includevoid main(){int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 1, 7, 8, 9, 0};printf("%u, %u", a+1, &a+1);}

A. 5474, 65488
B. 5480, 65488
C. 5480, 65496
D. 5474, 65476
E. one of these
Answer» D. 5474, 65476
7.

What will be the output of the following code?void main(){int a[10];printf("%d %d", a[-1], a[12]);}

A. 0
B. arbage value 0
C. Garbage Value
D. arbage vlaue Garbage Value
E. ode will not compile
Answer» E. ode will not compile
8.

Which of the following statements are correct about the program below?#includevoid main(){int size, i;scanf("%d", &size);int arr[size];for(i=1; i

A. he code is erroneous since the statement declaring array is invalid.
B. he code is erroneous since the subscript for array used in for loop is in the range 1 to size.
C. he code is correct and runs successfully.
D. he code is erroneous since the values of array are getting scanned through the loop.
E. one of these
Answer» B. he code is erroneous since the subscript for array used in for loop is in the range 1 to size.
9.

Which of the following is correct way to define the function fun() in the below program?#includevoid main(){int a[3][4];fun(a);}

A. oid fun(int p[][4]){}
B. oid fun(int *p[4]){}
C. oid fun(int *p[][4]){}
D. oid fun(int *p[3][4]){}
E. one of these
Answer» B. oid fun(int *p[4]){}
10.

What will be the output of the program if the array begins at address 65486?#includevoid main(){int arr[] = {12, 14, 15, 23, 45};printf("%u, %u", arr, &arr);}

A. 5486, 65488
B. 5486, 65490
C. 5486, 65487
D. 5486, 65486
E. one of these
Answer» E. one of these
11.

Let x be an array. Which of the following operations are illegal?I.++xII.x+1III.x++IV.x*2

A. and II
B. , II and III
C. I and III
D. , III and IV
E. II and IV
Answer» E. II and IV
12.

What will be the output of the program ?#includevoid main(){int a[5] = {5, 1, 15, 20, 25};int i, j, m;i = ++a[1];j = a[1]++;m = a[i++];printf("%d, %d, %d", i, j, m);}

A. , 2, 15
B. , 3, 20
C. , 1, 15
D. , 2, 5
Answer» B. , 3, 20
13.

String concatenation means -%!

A. Combining two strings.
B. Extracting a substring out of a string.
C. Partitioning the string into two strings.
D. Merging two strings.
E. Comparing the two strings to define the larger one.
Answer» B. Extracting a substring out of a string.
14.

The function sprintf() works like printf(), but operates on ..........%!

A. Data file
B. stderr
C. string
D. stdin
E. no such function in 'C'.
Answer» D. stdin
15.

What will be the correct output of the following program?#includevoid main(){ char str[] = "C EXAMINATION", rev[17]; int i = strlen(str), j=0; for( ; i>=0; rev[j++] = str[i--]); rev[j] = 'ÔøΩ'; puts(rev);}%!

A. NOITANIMAXE C
B. NOITANIMAXE
C. C
D. No output at all.
E. Syntax error
Answer» E. Syntax error
16.

Let x be an array. Which of the following operations are illegal?I. ¬¨‚Ä ++xII. x+1III. x++IV. x*2$

A. I and II
B. I, II and III
C. II and III
D. I, III and IV
E. III and IV
Answer» E. III and IV
17.

An array elements are always stored in ________ memory locations.

A. Sequential
B. Random
C. Sequential and Random
D. None of the above
Answer» B. Random
18.

What will be the output of following program code?#include int main(void){ char p; char buf[10] = {1, 2, 3, 4, 5, 6, 9, 8}; p = (buf + 1)[5]; printf("%d", p); return 0;}

A. 5
B. 6
C. 9
D. Error
E. None of the above
Answer» D. Error
19.

What will be the output of the program ?#includevoid main(){ int a[5] = {5, 1, 15, 20, 25}; int i, j, m; i = ++a[1]; j = a[1]++; m = a[i++]; printf("%d, %d, %d", i, j, m);}

A. 3, 2, 15
B. 2, 3, 20
C. 2, 1, 15
D. 1, 2, 5
Answer» B. 2, 3, 20
20.

What is right way to Initialize array?

A. int num[6] = { 2, 4, 12, 5, 45, 5 };
B. int n{} = { 2, 4, 12, 5, 45, 5 };
C. int n{6} = { 2, 4, 12 };
D. int n(6) = { 2, 4, 12, 5, 45, 5 };
Answer» B. int n{} = { 2, 4, 12, 5, 45, 5 };
21.

What will be the output of the following program?void main(){ char str1[] = "abcd"; char str2[] = "abcd"; if(str1==str2) printf("Equal"); else printf("Unequal");}

A. Equal
B. Unequal
C. Error
D. None of these.
Answer» C. Error
22.

What will be the output of the program ?#includeint main(){ int arr[1] = {10}; printf("%d", 0[arr]); return 0;}

A. 1
B. 0
C. 10
D. 6
E. None of these
Answer» D. 6
23.

What will be printed after execution of the following code?void main(){ int arr[10] = {1,2,3,4,5}; printf("%d", arr[5]);}

A. Garbage Value
B. 5
C. 6
D. 0
E. None of these
Answer» E. None of these
24.

What will be the output of the program if the array begins at 65472 and each integer occupies 2 bytes?#includevoid main(){ int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 1, 7, 8, 9, 0}; printf("%u, %u", a+1, &a+1);}

A. 65474, 65488
B. 65480, 65488
C. 65480, 65496
D. 65474, 65476
E. None of these
Answer» D. 65474, 65476
25.

Consider the following type definition.typedef char x[10];x myArray[5];What will sizeof(myArray) be ? (Assume one character occupies 1 byte)

A. 15
B. 10
C. 50
D. 30
E. None of these
Answer» D. 30
26.

Array passed as an argument to a function is interpreted as

A. Address of the array.
B. Values of the first elements of the array.
C. Address of the first element of the array.
D. Number of element of the array.
Answer» D. Number of element of the array.
27.

What does the following declaration mean?int (*ptr)[10];

A. ptr is array of pointers to 10 integers
B. ptr is a pointer to an array of 10 integers
C. ptr is an array of 10 integers
D. ptr is an pointer to array
Answer» C. ptr is an array of 10 integers
28.

What is the maximum number of dimensions an array in C may have?

A. 2
B. 8
C. 20
D. 50
E. Theoratically no limit. The only practical limits are memory size and compilers.
Answer» F.
29.

What will be the output of the following code?void main(){ int a[10]; printf("%d %d", a[-1], a[12]);}

A. 0 0
B. Garbage value 0
C. 0 Garbage Value
D. Garbage vlaue Garbage Value
E. Code will not compile
Answer» E. Code will not compile
30.

int a[5] = {1,2,3}What is the value of a[4]?

A. 3
B. 1
C. 2
D. 0
E. Garbage Value
Answer» E. Garbage Value
31.

What will be the output of the program ?#include#includevoid main(){ char str1[20] = "Hello", str2[20] = " World"; printf("%s", strcpy(str2, strcat(str1, str2)));}

A. Hello World
B. World
C. WorldHello
D. Hello
E. None of these
Answer» B. World
32.

Which of the following statements are correct about an array?1. The array int num[26]; can store 26 elements.2. The expression num[1] designates the very first element in the array.3. It is necessary to initialize the array at the time of declaration.4. The declaration num[SIZE] is allowed if SIZE is a macro.

A. 1
B. 1, 4
C. 2, 3
D. 2, 4
E. None of these
Answer» C. 2, 3
33.

What is the return value of the following statement if it is placed in C program? strcmp("ABC", "ABC");

A. 33
B. -1
C. 1
D. 0
E. Compilation Error
Answer» E. Compilation Error
34.

Which of the following statements are correct about the program below?#includevoid main(){ int size, i; scanf("%d", &size); int arr[size]; for(i=1; i

A. The code is erroneous since the statement declaring array is invalid.
B. The code is erroneous since the subscript for array used in for loop is in the range 1 to size.
C. The code is correct and runs successfully.
D. The code is erroneous since the values of array are getting scanned through the loop.
E. None of these
Answer» B. The code is erroneous since the subscript for array used in for loop is in the range 1 to size.
35.

Which of the following correctly accesses the seventh element stored in arr, an array with 100 elements?

A. arr[6]
B. arr[7]
C. arr{6}
D. arr{7}
E. None of these
Answer» B. arr[7]
36.

Which of the following is correct way to define the function fun() in the below program?#includevoid main(){ int a[3][4]; fun(a);}

A. void fun(int p[][4]){}
B. void fun(int *p[4]){}
C. void fun(int *p[][4]){}
D. void fun(int *p[3][4]){}
E. None of these
Answer» B. void fun(int *p[4]){}
37.

What will be the output of the program ?#include#includevoid main(){ char str[] = "Exam\0Veda"; printf("%s", str);}

A. Exam
B. Exam Veda
C. Exam\0Veda
D. Veda
E. None of these
Answer» B. Exam Veda
38.

What will be the output of the program ?#includevoid main(){ float arr[] = {12.4, 2.3, 4.5, 6.7}; printf("%d", sizeof(arr)/sizeof(arr[0]));}

A. 5
B. 4
C. 6
D. 7
E. None of these
Answer» C. 6
39.

What will be the output of the program ?#includevoid main(){ printf(5+"Good Morningn");}

A. Good Morning
B. M
C. Good
D. Morning
E. None of these
Answer» E. None of these
40.

What will be the output of the program if the array begins at address 65486?#includevoid main(){ int arr[] = {12, 14, 15, 23, 45}; printf("%u, %u", arr, &arr);}

A. 65486, 65488
B. 65486, 65490
C. 65486, 65487
D. 65486, 65486
E. None of these
Answer» E. None of these