MCQOPTIONS
Saved Bookmarks
This section includes 28 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 code:void main(){ int a[5] = {6,8,3,9,0}, i=0; if(i != 0) { break; printf("%d", a[i]); } else printf("%d", a[i++]);}What is the output of the above program?%! |
| A. | 6 |
| B. | 8 |
| C. | Runtime error |
| D. | Syntax error |
| E. | No output |
| Answer» E. No output | |
| 2. |
What will be printed if the following code is executed?void main(){ int x=0; for( ; ; ) { if( x++ == 4 ) break; continue; } printf("x=%d", x);}%! |
| A. | x=0 |
| B. | x=5 |
| C. | x=4 |
| D. | x=1 |
| E. | Error |
| Answer» C. x=4 | |
| 3. |
Consider the following program fragment:for(c=1, sum=0; c |
| A. | -5 |
| B. | 30 |
| C. | 10 |
| D. | 1 |
| E. | 15 |
| Answer» F. | |
| 4. |
*$_What will be the value of i and j after execution of following program?#includevoid main(){ int i, j; for(i=0,j=0;i |
| A. | 10 10 |
| B. | 10 20 |
| C. | 20 20 |
| D. | Run time error |
| Answer» D. Run time error | |
| 5. |
_ What will be the output of the given program?#includevoid main(){ int i=10; printf("i=%d", i); { int i=20; printf("i=%d", i); i++; printf("i=%d", i); } printf("i=%d", i);}$? |
| A. | 10 10 11 11 |
| B. | 10 20 21 21 |
| C. | 10 20 21 10 |
| D. | 10 20 21 20 |
| Answer» D. 10 20 21 20 | |
| 6. |
_What is the output of given program if user enter "xyz" ?#includevoid main(){ float age, AgeInSeconds; int value; printf("Enter your age:"); value=scanf("%f", &age); if(value==0){ printf("\\nYour age is not valid"); } AgeInSeconds = 365 * 24 * 60 * 60 * age; printf("\\n You have lived for %f seconds", AgeInSeconds);}$? |
| A. | Enter your age : xyz Your age is not valid |
| B. | Enter your age: xyz You have lived for 0 seconds |
| C. | Enter your age: xyz Your age is not valid |
| D. | Complier error |
| Answer» D. Complier error | |
| 7. |
What is the output of given program if user enter "xyz" ?#includevoid main(){ float age, AgeInSeconds; printf("Enter your age:"); scanf("%f", &age); AgeInSeconds = 365 * 24 * 60 * 60 * age; printf("You have lived for %f seconds", AgeInSeconds);}? |
| A. | Enter your age: xyz You have lived for 0 seconds |
| B. | Enter your age: xyz You have lived for 0.00000 seconds |
| C. | Enter your age: xyz "after that program will stop" |
| D. | Run time error |
| Answer» C. Enter your age: xyz "after that program will stop" | |
| 8. |
What is the output of given program if user enter value 99?#includevoid main(){ int i; printf("Enter a number:"); scanf("%d", &i); // 99 is given as input. if(i%5 == 0){ printf("nNumber entered is divisible by 5"); }} |
| A. | Enter a number:99 |
| B. | Enter a number:99 Number is divisible by 5 |
| C. | complier error |
| D. | Run time error |
| Answer» B. Enter a number:99 Number is divisible by 5 | |
| 9. |
What will be the output of the given program?#includevoid main(){ float num=5.6; switch(num){ case 5:printf("5"); case 6:printf("6"); default : printf("0"); break; } printf("%d", num);} |
| A. | 5 5.600000 |
| B. | 6 5.600000 |
| C. | 0 5.600000 |
| D. | Complier error |
| Answer» E. | |
| 10. |
What will be the output of the given program?#includevoid main(){ int value1, value2=100, num=100; if(value1=value2%5) num=5; printf("%d %d %d", num, value1, value2);} |
| A. | 100 100 100 |
| B. | 5 0 20 |
| C. | 5 0 100 |
| D. | 100 0 100 |
| E. | 100 5 100 |
| Answer» E. 100 5 100 | |
| 11. |
What will be the output of the given program?#includevoid main(){ int value=0; if(value) printf("well done "); printf("examveda");} |
| A. | well done examveda |
| B. | examveda |
| C. | complier error |
| D. | None of these |
| Answer» C. complier error | |
| 12. |
What will be the output of the given program?#includevoid main(){ int a=11,b=5; if(a=5) b++; printf("%d %d", ++a, b++);} |
| A. | 12 7 |
| B. | 5 6 |
| C. | 6 6 |
| D. | 6 7 |
| E. | 11 6 |
| Answer» D. 6 7 | |
| 13. |
What will be the output given program?#includevoid main(){ int i = -10; for(;i;printf("%d ", i++));} |
| A. | -10 to -1 |
| B. | -10 to infinite |
| C. | -10 to 0 |
| D. | Complier error |
| Answer» B. -10 to infinite | |
| 14. |
What will be the output of the following code?#includevoid main(){ int s=0; while(s++ |
| A. | 1 2 3 4 5 6 7 8 9 |
| B. | 1 2 3 10 |
| C. | 4 5 6 7 8 9 10 |
| D. | 4 5 6 7 8 9 |
| E. | None of these |
| Answer» D. 4 5 6 7 8 9 | |
| 15. |
What will be the output of the following piece of code?for(i = 0; i |
| A. | 10 |
| B. | 0123456789 |
| C. | Syntax error |
| D. | 0 |
| E. | Infinite loop |
| Answer» B. 0123456789 | |
| 16. |
What will be the output of given program?#includevoid main(){ int i=1, j=-1; if((printf("%d", i)) < (printf("%d", j))) printf("%d", i); else printf("%d", j);} |
| A. | 1 -1 1 |
| B. | 1 -1 -1 |
| C. | 1 |
| D. | -1 |
| E. | complier error |
| Answer» B. 1 -1 -1 | |
| 17. |
What will be the output of given program?#includevoid main(){ int a=3; for(;a;printf("%d ", a--);} |
| A. | no output |
| B. | 3 2 1 0 |
| C. | 3 2 1 |
| D. | infinity loop |
| Answer» D. infinity loop | |
| 18. |
What will be the output of given program?#includevoid main(){ int a=1; if("%d=hello", a);} |
| A. | complier error |
| B. | no error no output |
| C. | 0 |
| D. | 1 |
| Answer» C. 0 | |
| 19. |
What's wrong in the following statement, provided k is a variable of type int?for(k = 2, k |
| A. | The increment should always be ++k . |
| B. | The variable must always be the letter i when using a for loop. |
| C. | There should be a semicolon at the end of the statement. |
| D. | The variable k can’t be initialized. |
| E. | The commas should be semicolons. |
| Answer» F. | |
| 20. |
What will be the following code's output if choice = 'R'?switch(choice){ case 'R' : printf("RED"); case 'W' : printf("WHITE"); case 'B' : printf("BLUE"); default : printf("ERROR");break;} |
| A. | RED |
| B. | RED WHITE BLUE ERROR |
| C. | RED ERROR |
| D. | RED WHITE BLUE |
| E. | ERROR |
| Answer» C. RED ERROR | |
| 21. |
The type of the controlling expression of a switch statement cannot be of the type ........ |
| A. | int |
| B. | char |
| C. | short |
| D. | float |
| E. | long |
| Answer» E. long | |
| 22. |
What will be the final value of the digit?void main(){ int digit = 0; for( ; digit |
| A. | -1 |
| B. | 17 |
| C. | 19 |
| D. | 16 |
| E. | 20 |
| Answer» D. 16 | |
| 23. |
What is the output of the following statements?for(i=10; i++; i |
| A. | 10 11 12 13 14 |
| B. | 10 11 12 13 14 15 |
| C. | 9 10 11 12 13 |
| D. | Infinite loop |
| E. | None of these |
| Answer» E. None of these | |
| 24. |
What is the right choice, if the following loop is implemented?void main(){ int num = 0; do{ --num; printf("%d", num); }while( ++num >= 0 );} |
| A. | A run time error will be generated. |
| B. | The program will not enter into the loop. |
| C. | There will be a compilation error reported. |
| D. | The loop will run infinitely many times. |
| E. | Prints the value of 0 one time only. |
| Answer» E. Prints the value of 0 one time only. | |
| 25. |
What is the output of the following program?#includeint c[10] = {1,2,3,4,5,6,7,8,9,10}; main(){ int a, b=0; for(a=0;a |
| A. | 20 |
| B. | 24 |
| C. | 25 |
| D. | 30 |
| E. | None of these |
| Answer» D. 30 | |
| 26. |
What will be the value of sum after the following program is executed?void main(){ int sum=1, index = 9; do{ index = index – 1; sum *= 2; }while( index > 9 );} |
| A. | 1 |
| B. | 2 |
| C. | 9 |
| D. | 0.5 |
| E. | 0.25 |
| Answer» C. 9 | |
| 27. |
Which command is used to skip the rest of a loop and carry on from the top of the loop again? |
| A. | break |
| B. | resume |
| C. | continue |
| D. | skip |
| E. | None of these |
| Answer» D. skip | |
| 28. |
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 | |