Explore topic-wise MCQs in C Programming.

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

1.

Which of the following correctly represents a constant?

A. 6.68
B. 6.68L
C. 6.68f
D. 6.68LF
Answer» C. 6.68f
2.

Which of the structure is incorrcet?

A. 1
B. 2
C. 3
D. 1, 2, 3
Answer» C. 3
3.

Which of the structure is correct?

A. 1
B. 2
C. 3
D. All of above
Answer» B. 2
4.

A can be used if range of a is not enough to accommodate a real number.

A. True
B. False
Answer» B. False
5.

A is 4 bytes wide, whereas a is 8 bytes wide.

A. True
B. False
Answer» B. False
6.

If the definition of the external variable occurs in the source file before its use in a particular function, then there is no need for an declaration in the function.

A. True
B. False
Answer» B. False
7.

Size of and can be verified using the operator.

A. True
B. False
Answer» B. False
8.

Range of is -1.7e-38 to 1.7e+38 (in 16 bit platform - Turbo C under DOS)

A. True
B. False
Answer» C.
9.

Size of and would vary from one platform to another.

A. True
B. False
Answer» B. False
10.

Range of id -2.25e+308 to 2.25e+308

A. True
B. False
Answer» C.
11.

Which of the following is not user defined data type?

A. 1
B. 2
C. 3
D. Both 1 and 2
Answer» C. 3
12.

Is the following statement a declaration or definition?

A. Declaration
B. Definition
C. Function
D. Error
Answer» B. Definition
13.

Identify which of the following are declarations

A. 1
B. 2
C. 1 and 3
D. 3
Answer» D. 3
14.

Is there any difference in the following declarations?

A. Yes
B. No
Answer» B. No
15.

Suppose a program is divided into three files and , and a variable is defined in the file but used in files and . In such a case would we need the declaration for the variables in the files and ?

A. Yes
B. No
Answer» B. No
16.

Is there any difference between following declarations?

A. Both are identical
B. No difference, except
C. is probably in another file
D. is overrided with
E. None of these
Answer» C. is probably in another file
17.

Identify which of the following are declarations_x000D_ _x000D_ _x000D_ 1 :_x000D_ extern int x;_x000D_ _x000D_ _x000D_ 2 :_x000D_ float square ( float x ) { ... }_x000D_ _x000D_ _x000D_ 3 :_x000D_ double pow(double, double);

A. 1
B. 2
C. 1 and 3
D. 3
Answer» D. 3
18.

Is the following statement a declaration or definition?_x000D_ extern int i;

A. Declaration
B. Definition
C. Function
D. Error
Answer» B. Definition
19.

Which of the following is not user defined data type?_x000D_ _x000D_ _x000D_ 1 :_x000D_ struct book_x000D_ {_x000D_ char name[10];_x000D_ float price;_x000D_ int pages;_x000D_ };_x000D_ _x000D_ _x000D_ 2 :_x000D_ long int l = 2.35;_x000D_ _x000D_ _x000D_ 3 :_x000D_ enum day {Sun, Mon, Tue, Wed};

A. 1
B. 2
C. 3
D. Both 1 and 2
Answer» C. 3
20.

What is the output of the program_x000D_ #include_x000D_ int main()_x000D_ {_x000D_ int a[5] = {2, 3};_x000D_ printf("%d, %d, %d\n", a[2], a[3], a[4]);_x000D_ return 0;_x000D_ }

A. Garbage Values
B. 2, 3, 3
C. 3, 2, 2
D. 0, 0, 0
Answer» E.
21.

What is the output of the program_x000D_ #include_x000D_ int main()_x000D_ {_x000D_ struct emp_x000D_ {_x000D_ char name[20];_x000D_ int age;_x000D_ float sal;_x000D_ };_x000D_ struct emp e = {"Tiger"};_x000D_ printf("%d, %f\n", e.age, e.sal);_x000D_ return 0;_x000D_ }

A. 0, 0.000000
B. Garbage values
C. Error
D. None of above
Answer» B. Garbage values
22.

What will be the output of the program?_x000D_ #include_x000D_ int main()_x000D_ {_x000D_ int X=40;_x000D_ {_x000D_ int X=20;_x000D_ printf("%d ", X);_x000D_ }_x000D_ printf("%d\n", X);_x000D_ return 0;_x000D_ }

A. 40 40
B. 20 40
C. 20
D. Error
Answer» C. 20
23.

What will be the output of the program?_x000D_ #include_x000D_ int X=40;_x000D_ int main()_x000D_ {_x000D_ int X=20;_x000D_ printf("%d\n", X);_x000D_ return 0;_x000D_ }

A. 20
B. 40
C. Error
D. No Output
Answer» B. 40
24.

What is the output of the program? #include int main() { union a { int i; char ch[2]; }; union a u; u.ch[0] = 3; u.ch[1] = 2; printf("%d, %d, %d\n", u.ch[0], u.ch[1], u.i); return 0; }

A. 3, 2, 515
B. 515, 2, 3
C. 3, 2, 5
D. None of these
Answer» B. 515, 2, 3
25.

What will be the output of the program? #include int main() { int X=40; { int X=20; printf("%d ", X); } printf("%d\n", X); return 0; }

A. 40 40
B. 20 40
C. 20
D. Error
Answer» C. 20
26.

Range of float id -2.25e+308 to 2.25e+308

A. 1
B.
Answer» C.
27.

What is the output of the program #include int main() { int x = 10, y = 20, z = 5, i; i = x < y < z; printf("%d\n", i); return 0; }

A. 0
B. 1
C. Error
D. None of these
Answer» C. Error
28.

What is the output of the program #include int main() { extern int fun(float); int a; a = fun(3.14); printf("%d\n", a); return 0; } int fun(int aa) { return (int)++aa; }

A. 3
B. 3.14
C. 0 
D. 4
Answer» E.
29.

What is the output of the program #include int main() { int a[5] = {2, 3}; printf("%d, %d, %d\n", a[2], a[3], a[4]); return 0; }

A. Garbage Values
B. 2, 3, 3
C. 3, 2, 2
D. 0, 0, 0
Answer» E.
30.

Is it true that a global variable may have several declarations, but only one definition?

A. Yes
B. No
Answer» B. No
31.

Point out the error in the following program. #include int main() { void v = 0; printf("%d", v); return 0; }

A. Error: Declaration syntax error 'v' (or) Size of v is unknown or zero.
B. Program terminates abnormally.
C. No error.
D. None of these.
Answer» B. Program terminates abnormally.
32.

What is the output of the program #include int main() { struct emp { char name[20]; int age; float sal; }; struct emp e = {"Tiger"}; printf("%d, %f\n", e.age, e.sal); return 0; }

A. 0, 0.000000
B. Garbage values
C. Error
D. None of above
Answer» B. Garbage values
33.

Which of the following is not user defined data type? 1 : struct book { char name[10]; float price; int pages; }; 2 : long int l = 2.35; 3 : enum day {Sun, Mon, Tue, Wed};

A. 1
B. 2
C. 3
D. Both 1 and 2
Answer» C. 3
34.

What will be the output of the program in 16 bit platform (Turbo C under DOS)? #include int main() { extern int i; i = 20; printf("%d\n", sizeof(i)); return 0; }

A. 2
B. 4
C. vary from compiler
D. Linker Error : Undefined symbol 'i'
Answer» E.
35.

What is the output of the program in Turbo C (in DOS 16-bit OS)? #include int main() { char *s1; char far *s2; char huge *s3; printf("%d, %d, %d\n", sizeof(s1), sizeof(s2), sizeof(s3)); return 0; }

A. 2, 4, 6
B. 4, 4, 2
C. 2, 4, 4
D. 2, 2, 2
Answer» D. 2, 2, 2
36.

Which of the structure is incorrcet? 1 : struct aa { int a; float b; }; 2 : struct aa { int a; float b; struct aa var; }; 3 : struct aa { int a; float b; struct aa *var; };

A. 1
B. 2
C. 3
D. 1, 2, 3
Answer» C. 3
37.

Which of the structure is correct? 1 : struct book { char name[10]; float price; int pages; }; 2 : struct aa { char name[10]; float price; int pages; } 3 : struct aa { char name[10]; float price; int pages; }

A. 1
B. 2
C. 3
D. All of above
Answer» B. 2
38.

Point out the error in the following program. #include int main() { int (*p)() = fun; (*p)(); return 0; } int fun() { printf("IndiaBix.com\n"); return 0; }

A. Error: in int(*p)() = fun;
B. Error: fun() prototype not defined
C. No error
D. None of these
Answer» C. No error
39.

Size of short integer and long integer would vary from one platform to another.

A. 1
B.
C. 1
D.
Answer» B.
40.

Suppose a program is divided into three files f1, f2 and f3, and a variable is defined in the file f1 but used in files f2 and f3. In such a case would we need the extern declaration for the variables in the files f2 and f3?

A. Yes
B. No
Answer» B. No
41.

Identify which of the following are declarations 1 : extern int x; 2 : float square ( float x ) { ... } 3 : double pow(double, double);

A. 1
B. 2
C. 1 and 3
D. 3
Answer» D. 3
42.

In the following program how long will the for loop get executed? #include int main() { int i=5; for(;scanf("%s", &i); printf("%d\n", i)); return 0; }

A. The for loop would not get executed at all
B. The for loop would get executed only once
C. The for loop would get executed 5 times
D. The for loop would get executed infinite times
Answer» E.
43.

A float is 4 bytes wide, whereas a double is 8 bytes wide.

A. 1
B.
Answer» B.
44.

In the following program where is the variable a getting defined and where it is getting declared? #include int main() { extern int a; printf("%d\n", a); return 0; } int a=20;

A. extern int a is declaration, int a = 20 is the definition
B. int a = 20 is declaration, extern int a is the definition
C. int a = 20 is definition, a is not defined
D. a is declared, a is not defined
Answer» B. int a = 20 is declaration, extern int a is the definition
45.

Range of double is -1.7e-38 to 1.7e+38 (in 16 bit platform - Turbo C under DOS)

A. 1
B.
Answer» C.
46.

If the definition of the external variable occurs in the source file before its use in a particular function, then there is no need for an extern declaration in the function.

A. 1
B.
Answer» B.
47.

Is the following statement a declaration or definition? extern int i;

A. Declaration
B. Definition
C. Function
D. Error
Answer» B. Definition
48.

Which of the following correctly represents a long double constant?

A. 6.68
B. 6.68L
C. 6.68f
D. 6.68LF
Answer» C. 6.68f
49.

What will be the output of the program? #include int X=40; int main() { int X=20; printf("%d\n", X); return 0; }

A. 20
B. 40
C. Error
D. No Output
Answer» B. 40
50.

Size of short integer and long integer can be verified using the sizeof() operator.

A. 1
B.
Answer» B.