MCQOPTIONS
Saved Bookmarks
This section includes 36 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. |
Consider the following program fragment, and choose the correct onevoid main(){int a, b = 2, c;a = 2 * (b++);c = 2 * (++b);} |
| A. | = 4, c = 8 |
| B. | = 3, c = 8 |
| C. | = 3, c = 6 |
| D. | = 4, c = 6 |
| E. | = 4, c = 6 |
| Answer» B. = 3, c = 8 | |
| 2. |
Choose the correct output for the following program.#includevoid main(){int a=10, b=11, c=13, d;d = (a=c, b+=a, c=a+b+c);printf("%d %d %d %d", d, a, b, c);} |
| A. | 0, 13, 11, 13 |
| B. | 0, 13, 24, 50 |
| C. | 3, 10, 24, 50 |
| D. | 0, 13, 24, 13 |
| E. | 3, 13, 24, 13 |
| Answer» C. 3, 10, 24, 50 | |
| 3. |
Determine output of the following program code.#includevoid main(){int a, b=7;a = b1 : a;printf("%d %d", a, b);} |
| A. | 7 |
| B. | 3 |
| C. | 3 |
| D. | 8 |
| E. | one of these |
| Answer» E. one of these | |
| 4. |
Find the output of the following program.#includevoid main(){int y=10;if(y++>9 && y++!=11 && y++>11)printf("%d", y);elseprintf("%d", y);} |
| A. | 1 |
| B. | 2 |
| C. | 3 |
| D. | 4 |
| E. | ompilation error |
| Answer» C. 3 | |
| 5. |
Find the output of the following program.#includevoid main(){int y=10;if(y++>9 && y++!=10 && y++>11)printf("%d", y);elseprintf("%d", y);} |
| A. | 1 |
| B. | 2 |
| C. | 3 |
| D. | 4 |
| E. | ompilation error |
| Answer» D. 4 | |
| 6. |
void main(){int a=10, b;b = a++ + ++a;printf("%d %d %d %d", b, a++, a, ++a);}what will be the output when following code is executed? |
| A. | 2 10 11 13 |
| B. | 2 12 12 13 |
| C. | 2 11 11 11 |
| D. | 2 14 12 13 |
| E. | 2 13 14 14 |
| Answer» F. | |
| 7. |
Identify the correct output of the following code:void main(){int w=10, x=5, y=3, z=3;if( (w < x ) && (y=z++) )printf("%d %d %d %d", w, x, y, z);elseprintf("%d %d %d %d", w, x, y, z);} |
| A. | 0544 |
| B. | 0533 |
| C. | 0543 |
| D. | 0534 |
| E. | 0555 |
| Answer» C. 0543 | |
| 8. |
What will be the output of the following code fragment?void main(){printf("%x",-1 |
| A. | ff0 |
| B. | ff1 |
| C. | ff2 |
| D. | ff3 |
| E. | ff4 |
| Answer» B. ff1 | |
| 9. |
What will be the output?void main(){int a=10, b=20;char x=1, y=0;if(a,b,x,y){printf("EXAM");}} |
| A. | AM is printed |
| B. | xam is printed |
| C. | ompiler Error |
| D. | othing is printed |
| Answer» E. | |
| 10. |
Determine output:void main(){int i=10;i = !i>14;printf("i=%d", i);} |
| A. | 0 |
| B. | 4 |
| C. | |
| Answer» D. | |
| 11. |
Determine output:void main(){int i=0, j=1, k=2, m;m = i++ || j++ || k++;printf("%d %d %d %d", m, i, j, k);} |
| A. | 1 2 3 |
| B. | 1 2 2 |
| C. | 1 2 2 |
| D. | 1 2 3 |
| E. | one of these |
| Answer» C. 1 2 2 | |
| 12. |
In an expression involving || operator, evaluationI.Will be stopped if one of its components evaluates to falseII.Will be stopped if one of its components evaluates to trueIII. Takes place from right to leftIV.Takes place from left to right |
| A. | and II |
| B. | and III |
| C. | I and III |
| D. | I and IV |
| E. | II and IV |
| Answer» E. II and IV | |
| 13. |
void main(){ int a=10, b; b = a++ + ++a; printf("%d %d %d %d", b, a++, a, ++a);}what will be the output when following code is executed?%! |
| A. | 12 10 11 13 |
| B. | 22 12 12 13 |
| C. | 22 11 11 11 |
| D. | 22 14 12 13 |
| E. | 22 13 14 14 |
| Answer» F. | |
| 14. |
Given b=110 and c=20, what is the value of 'a' after execution of the expression a=b-=c*=5?%! |
| A. | 450 |
| B. | 10 |
| C. | 110 |
| D. | -10 |
| E. | -110 |
| Answer» C. 110 | |
| 15. |
Identify the correct output of the following code:void main(){ int w=10, x=5, y=3, z=3; if( (w < x ) && (y=z++) ) printf("%d %d %d %d", w, x, y, z); else printf("%d %d %d %d", w, x, y, z);}%! |
| A. | 10 5 4 4 |
| B. | 10 5 3 3 |
| C. | 10 5 4 3 |
| D. | 10 5 3 4 |
| E. | 10 5 5 5 |
| Answer» C. 10 5 4 3 | |
| 16. |
Which operator from the following has the lowest priority?%! |
| A. | Assignment operator |
| B. | Division operator |
| C. | Comma operator |
| D. | Conditional operator |
| E. | Unary-operator |
| Answer» D. Conditional operator | |
| 17. |
Which operator has the lowest priority? |
| A. | ++ |
| B. | % |
| C. | + |
| D. | || |
| E. | && |
| Answer» E. && | |
| 18. |
What will be the output of this program on an implementation where int occupies 2 bytes?#include void main(){ int i = 3; int j; j = sizeof(++i + ++i); printf("i=%d j=%d", i, j);} |
| A. | i=4 j=2 |
| B. | i=3 j=2 |
| C. | i=5 j=2 |
| D. | the behavior is undefined |
| Answer» C. i=5 j=2 | |
| 19. |
Which of the following comments about the ++ operator are correct? |
| A. | It is a unary operator |
| B. | The operand can come before or after the operator |
| C. | It cannot be applied to an expression |
| D. | It associates from the right |
| E. | All of the above |
| Answer» F. | |
| 20. |
What will be the output of the following program?void main(){ int a, b, c, d; a = 3; b = 5; c = a, b; d = (a, b); printf("c=%d d=%d", c, d);} |
| A. | c=3 d=3 |
| B. | c=3 d=5 |
| C. | c=5 d=3 |
| D. | c=5 d=5 |
| Answer» C. c=5 d=3 | |
| 21. |
In C programming language, which of the following type of operators have the highest precedence |
| A. | Relational operators |
| B. | Equality operators |
| C. | Logical operators |
| D. | Arithmetic operators |
| Answer» E. | |
| 22. |
What will be the output of the following code fragment?void main(){ printf("%x",-1 |
| A. | fff0 |
| B. | fff1 |
| C. | fff2 |
| D. | fff3 |
| E. | fff4 |
| Answer» B. fff1 | |
| 23. |
Determine output:void main(){ int i=10; i = !i>14; printf("i=%d", i); } |
| A. | 10 |
| B. | 14 |
| C. | 0 |
| D. | 1 |
| E. | None of these |
| Answer» D. 1 | |
| 24. |
What is the output of the following statements?int b=15, c=5, d=8, e=8, a;a = b>c ? c>d ? 12 : d>e ? 13 : 14 : 15;printf("%d", a); |
| A. | 13 |
| B. | 14 |
| C. | 15 |
| D. | 12 |
| E. | Garbage Value |
| Answer» C. 15 | |
| 25. |
Determine output:void main(){ int c = - -2; printf("c=%d", c); } |
| A. | 1 |
| B. | -2 |
| C. | 2 |
| D. | Error |
| Answer» D. Error | |
| 26. |
What is the output of the following statements?int i = 0;printf("%d %d", i, i++); |
| A. | 0 1 |
| B. | 1 0 |
| C. | 0 0 |
| D. | 1 1 |
| E. | None of these |
| Answer» C. 0 0 | |
| 27. |
Determine output:void main(){ int i=0, j=1, k=2, m; m = i++ || j++ || k++; printf("%d %d %d %d", m, i, j, k);} |
| A. | 1 1 2 3 |
| B. | 1 1 2 2 |
| C. | 0 1 2 2 |
| D. | 0 1 2 3 |
| E. | None of these |
| Answer» C. 0 1 2 2 | |
| 28. |
What number will z in the sample code given below?int z, x=5, y= -10, a=4, b=2;z = x++ - --y*b/a; |
| A. | 5 |
| B. | 6 |
| C. | 9 |
| D. | 10 |
| E. | 11 |
| Answer» E. 11 | |
| 29. |
In an expression involving || operator, evaluationI.¬¨‚Ä ¬¨‚Ä ¬¨‚Ä Will be stopped if one of its components evaluates to falseII.¬¨‚Ä ¬¨‚Ä Will be stopped if one of its components evaluates to trueIII.¬¨‚Ä Takes place from right to leftIV.¬¨‚Ä ¬¨‚Ä Takes place from left to right$ |
| A. | I and II |
| B. | I and III |
| C. | II and III |
| D. | II and IV |
| E. | III and IV |
| Answer» E. III and IV | |
| 30. |
What will be the output?void main(){ int a=10, b=20; char x=1, y=0; if(a,b,x,y){ printf("EXAM"); } } |
| A. | XAM is printed |
| B. | exam is printed |
| C. | Compiler Error |
| D. | Nothing is printed |
| Answer» E. | |
| 31. |
Which of the following operator takes only integer operands? |
| A. | + |
| B. | * |
| C. | / |
| D. | % |
| E. | None of these |
| Answer» E. None of these | |
| 32. |
Consider the following program fragment, and choose the correct onevoid main(){ int a, b = 2, c; a = 2 * (b++); c = 2 * (++b);} |
| A. | a = 4, c = 8 |
| B. | a = 3, c = 8 |
| C. | b = 3, c = 6 |
| D. | a = 4, c = 6 |
| E. | b = 4, c = 6 |
| Answer» B. a = 3, c = 8 | |
| 33. |
Choose the correct output for the following program.#includevoid main(){ int a=10, b=11, c=13, d; d = (a=c, b+=a, c=a+b+c); printf("%d %d %d %d", d, a, b, c);} |
| A. | 50, 13, 11, 13 |
| B. | 50, 13, 24, 50 |
| C. | 13, 10, 24, 50 |
| D. | 50, 13, 24, 13 |
| E. | 13, 13, 24, 13 |
| Answer» C. 13, 10, 24, 50 | |
| 34. |
Determine output of the following program code.#includevoid main(){ int a, b=7; a = b1 : a; printf("%d %d", a, b);} |
| A. | 3 7 |
| B. | 7 3 |
| C. | 8 3 |
| D. | 3 8 |
| E. | None of these |
| Answer» E. None of these | |
| 35. |
Find the output of the following program.#includevoid main(){ int y=10; if(y++>9 && y++!=11 && y++>11) printf("%d", y); else printf("%d", y);} |
| A. | 11 |
| B. | 12 |
| C. | 13 |
| D. | 14 |
| E. | Compilation error |
| Answer» C. 13 | |
| 36. |
Find the output of the following program.#includevoid main(){ int y=10; if(y++>9 && y++!=10 && y++>11) printf("%d", y); else printf("%d", y);} |
| A. | 11 |
| B. | 12 |
| C. | 13 |
| D. | 14 |
| E. | Compilation error |
| Answer» D. 14 | |