Explore topic-wise MCQs in C Programming.

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

151.

The value obtained in the function is given back to main by using ________ keyword.

A. return
B. static
C. new
D. volatile
Answer» B. static
152.

Which of the following file extensions are accepted with #include?

A. .h
B. .in
C. .com
D. All of the mentioned
Answer» E.
153.

The #elif directive cannot appear after the preprocessor #else directive.

A. True
B. False
C. None of the mentioned
D. Varies
Answer» B. False
154.

What is a preprocessor?

A. That processes its input data to produce output that is used as input to another program
B. That is nothing but a loader
C. That links various source files
D. All of the mentioned
Answer» B. That is nothing but a loader
155.

#include statement must be written __________

A. Before main()
B. Before any scanf/printf
C. After main()
D. It can be written anywhere
Answer» C. After main()
156.

If storage class is not specified for a local variable, then the default class will be auto.

A. True
B. False
C. Depends on the standard
D. None of the mentioned
Answer» B. False
157.

If the file name is enclosed in double quotation marks, then _________

A. The preprocessor treats it as a user-defined file
B. The preprocessor treats it as a system-defined file
C. The preprocessor treats it as a user-defined file & system-defined file
D. None of the mentioned
Answer» B. The preprocessor treats it as a system-defined file
158.

If the file name is enclosed in angle brackets, then ___________

A. The preprocessor treats it as a user-defined file
B. The preprocessor treats it as a system-defined file
C. The preprocessor treats it as a user-defined file & system-defined file
D. None of the mentioned
Answer» C. The preprocessor treats it as a user-defined file & system-defined file
159.

In a conditional inclusion, if the condition that comes after the if is true, then what will happen during compilation?

A. Then the code up to the following #else or #elif or #endif is compiled
B. Then the code up to the following #endif is compiled even if #else or #elif is present
C. Then the code up to the following #eliif is compiled
D. None of the mentioned
Answer» B. Then the code up to the following #endif is compiled even if #else or #elif is present
160.

For each #if, #ifdef, and #ifndef directive.

A. There are zero or more #elif directives
B. Zero or one #else directive
C. One matching #endif directive
D. All of the mentioned
Answer» E.
161.

What will be the output of the program? #include int fun(int(*)()); int main() { fun(main); printf("Hi\n"); return 0; } int fun(int (*p)()) { printf("Hello "); return 0; }

A. Infinite loop
B. Hi
C. Hello Hi
D. Error
Answer» D. Error
162.

What will be the output of the program? #include int addmult(int ii, int jj) { int kk, ll; kk = ii + jj; ll = ii * jj; return (kk, ll); } int main() { int i=3, j=4, k, l; k = addmult(i, j); l = addmult(i, j); printf("%d, %d\n", k, l); return 0; }

A. 12, 12
B. 7, 7
C. 7, 12
D. 12, 7
Answer» B. 7, 7
163.

What will be the output of the program? #include int fun(int, int); typedef int (*pf) (int, int); int proc(pf, int, int); int main() { printf("%d\n", proc(fun, 6, 6)); return 0; } int fun(int a, int b) { return (a==b); } int proc(pf p, int a, int b) { return ((*p)(a, b)); }

A. 6
B. 1
C. 0
D. -1
Answer» C. 0
164.

What will be the output of the program? #include int i; int fun1(int); int fun2(int); int main() { extern int j; int i=3; fun1(i); printf("%d,", i); fun2(i); printf("%d", i); return 0; } int fun1(int j) { printf("%d,", ++j); return 0; } int fun2(int i) { printf("%d,", ++i); return 0; } int j=1;

A. 3, 4, 4, 3
B. 4, 3, 4, 3
C. 3, 3, 4, 4
D. 3, 4, 3, 4
Answer» C. 3, 3, 4, 4
165.

Is it true that too many recursive calls may result into stack overflow?

A. Yes
B. No
Answer» B. No
166.

What will be the output of the program? #include int main() { int fun(int); int i = fun(10); printf("%d\n", --i); return 0; } int fun(int i) { return (i++); }

A. 9
B. 10
C. 11
D. 8
Answer» B. 10
167.

If int is 2 bytes wide.What will be the output of the program? #include void fun(char**); int main() { char *argv[] = {"ab", "cd", "ef", "gh"}; fun(argv); return 0; } void fun(char **p) { char *t; t = (p+= sizeof(int))[-1]; printf("%s\n", t); }

A. ab
B. cd
C. ef
D. gh
Answer» C. ef
168.

What will be the output of the program? #include int fun(int); int main() { float k=3; fun(k=fun(fun(k))); printf("%f\n", k); return 0; } int fun(int i) { i++; return i; }

A. 5
B. 3
C. Garbage value
D. 4
Answer» B. 3
169.

What will be the output of the program? #include int addmult(int ii, int jj) { int kk, ll; kk = ii + jj; ll = ii * jj; return (kk, ll); } int main() { int i=3, j=4, k, l; k = addmult(i, j); l = addmult(i, j); printf("%d %d\n", k, l); return 0; }

A. 12 12
B. No error, No output
C. Error: Compile error
D. None of above
Answer» B. No error, No output
170.

What will be the output of the program? #include int func1(int); int main() { int k=35; k = func1(k=func1(k=func1(k))); printf("k=%d\n", k); return 0; } int func1(int k) { k++; return k; }

A. k=35
B. k=36
C. k=37
D. k=38
Answer» E.
171.

In a function two return statements should never occur.

A. Yes
B. No
Answer» C.
172.

What will be the output of the program? #include int fun(int i) { i++; return i; } int main() { int fun(int); int i=3; fun(i=fun(fun(i))); printf("%d\n", i); return 0; }

A. 5
B. 4
C. Error
D. Garbage value
Answer» B. 4
173.

What will be the output of the program? #include int main() { void fun(char*); char a[100]; a[0] = 'A'; a[1] = 'B'; a[2] = 'C'; a[3] = 'D'; fun(&a[0]); return 0; } void fun(char *a) { a++; printf("%c", *a); a++; printf("%c", *a); }

A. AB
B. BC
C. CD
D. No output
Answer» C. CD
174.

Names of functions in two different files linked together must be unique

A. 1
B.
Answer» B.
175.

What will be the output of the program? #include int check (int, int); int main() { int c; c = check(10, 20); printf("c=%d\n", c); return 0; } int check(int i, int j) { int *p, *q; p=&i; q=&j; i>=45 ? return(*p): return(*q); }

A. Print 10
B. Print 20
C. Print 1
D. Compile error
Answer» E.
176.

What will be the output of the program? #include int check(int); int main() { int i=45, c; c = check(i); printf("%d\n", c); return 0; } int check(int ch) { if(ch >= 45) return 100; else return 10; }

A. 100
B. 10
C. 1
D. 0
Answer» B. 10
177.

Maximum number of arguments that a function can take is 12

A. Yes
B. No
Answer» C.
178.

What will be the output of the program? #include void fun(int*, int*); int main() { int i=5, j=2; fun(&i, &j); printf("%d, %d", i, j); return 0; } void fun(int *i, int *j) { *i = *i**i; *j = *j**j; }

A. 5, 2
B. 10, 4
C. 2, 5
D. 25, 4
Answer» E.
179.

Will the following functions work? int f1(int a, int b) { return ( f2(20) ); } int f2(int a) { return (a*a); }

A. Yes
B. No
Answer» B. No
180.

Functions cannot return more than one value at a time

A. 1
B.
Answer» B.
181.

A function may have any number of return statements each returning different values.

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

What will be the output of the program? #include int main() { int i=1; if(!i) printf("IndiaBIX,"); else { i=0; printf("C-Program"); main(); } return 0; }

A. prints "IndiaBIX, C-Program" infinitely
B. prints "C-Program" infinetly
C. prints "C-Program, IndiaBIX" infinitely
D. Error: main() should not inside else statement
Answer» C. prints "C-Program, IndiaBIX" infinitely
183.

Usually recursion works slower than loops.

A. Yes
B. No
C. Yes
D. No
Answer» B. No
184.

Every function must return a value

A. Yes
B. No
Answer» C.
185.

Point out the error in the program #include int f(int a) { a > 20? return(10): return(20); } int main() { int f(int); int b; b = f(20); printf("%d\n", b); return 0; }

A. Error: Prototype declaration
B. No error
C. Error: return statement cannot be used with conditional operators
D. None of above
Answer» D. None of above
186.

If a function contains two return statements successively, the compiler will generate warnings. Yes/No ?

A. Yes
B. No
Answer» B. No
187.

Functions can be called either by value or reference

A. 1
B.
Answer» B.
188.

What will be the output of the program? #include int sumdig(int); int main() { int a, b; a = sumdig(123); b = sumdig(123); printf("%d, %d\n", a, b); return 0; } int sumdig(int n) { int s, d; if(n!=0) { d = n%10; n = n/10; s = d+sumdig(n); } else return 0; return s; }

A. 4, 4
B. 3, 3
C. 6, 6
D. 12, 12
Answer» D. 12, 12
189.

Which of the following statements are correct about the function? long fun(int num) { int i; long f=1; for(i=1; i<=num; i++) f = f * i; return f; }

A. The function calculates the value of 1 raised to power num.
B. The function calculates the square root of an integer
C. The function calculates the factorial value of an integer
D. None of above
Answer» D. None of above
190.

If return type for a function is not specified, it defaults to int

A. 1
B.
Answer» B.
191.

Point out the error in the program #include int main() { int a=10; void f(); a = f(); printf("%d\n", a); return 0; } void f() { printf("Hi"); }

A. Error: Not allowed assignment
B. Error: Doesn't print anything
C. No error
D. None of above
Answer» B. Error: Doesn't print anything
192.

What will be the output of the program? #include int reverse(int); int main() { int no=5; reverse(no); return 0; } int reverse(int no) { if(no == 0) return 0; else printf("%d,", no); reverse (no--); }

A. Print 5, 4, 3, 2, 1
B. Print 1, 2, 3, 4, 5
C. Print 5, 4, 3, 2, 1, 0
D. Infinite loop
Answer» E.
193.

What will be the output of the program? #include #include int main() { int i=0; i++; if(i<=5) { printf("IndiaBIX"); exit(1); main(); } return 0; }

A. Prints "IndiaBIX" 5 times
B. Function main() doesn't calls itself
C. Infinite loop
D. Prints "IndiaBIx"
Answer» E.
194.

What will be the output of the program? #include int i; int fun(); int main() { while(i) { fun(); main(); } printf("Hello\n"); return 0; } int fun() { printf("Hi"); }

A. Hello
B. Hi Hello
C. No output
D. Infinite loop
Answer» B. Hi Hello
195.

There is a error in the below program. Which statement will you add to remove it? #include int main() { int a; a = f(10, 3.14); printf("%d\n", a); return 0; } float f(int aa, float bb) { return ((float)aa + bb); }

A. Add prototype: float f(aa, bb)
B. Add prototype: float f(int, float)
C. Add prototype: float f(float, int)
D. Add prototype: float f(bb, aa)
Answer» C. Add prototype: float f(float, int)
196.

What will be the output of the program? #include void fun(int); typedef int (*pf) (int, int); int proc(pf, int, int); int main() { int a=3; fun(a); return 0; } void fun(int n) { if(n > 0) { fun(--n); printf("%d,", n); fun(--n); } }

A. 0, 2, 1, 0,
B. 1, 1, 2, 0,
C. 0, 1, 0, 2,
D. 0, 1, 2, 0,
Answer» E.
197.

In C all functions except main() can be called recursively.

A. 1
B.
Answer» C.
198.

How many times the program will print "IndiaBIX" ? #include int main() { printf("IndiaBIX"); main(); return 0; }

A. Infinite times
B. 32767 times
C. 65535 times
D. Till stack overflows
Answer» E.
199.

Point out the error in the program f(int a, int b) { int a; a = 20; return a; }

A. Missing parenthesis in return statement
B. The function should be defined as int f(int a, int b)
C. Redeclaration of a
D. None of above
Answer» D. None of above
200.

A function cannot be defined inside another function

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