Trivia Quiz: Could You Really Pass This C++ Test?

36 Questions | Total Attempts: 91

Trivia Quiz: Could You Really Pass This C++ Test? - Quiz

Could you really pass this C++ test? Do you think you know everything about the language? Well you are in luck as the quiz below perfect for you, and it has combined some questions from past certification exams, and if you are able to get even three-quarters of the mark, you have nothing to worry about when it comes to the finals. Give it a try!

Questions and Answers
  • 1. 
    What is the correct value to return to the operating system upon the successful completion of a program?   A. -1  B. 1  C. 0  D. Programs do not return a value.
  • 2. 
     What is the only function all C programs must contain? A. start() B. system()  C. main()  D. program()
  • 3. 
     What punctuation is used to signal the beginning and end of code blocks? A. { }  B. -> and <-  C. BEGIN and END  D. ( and ) 
  • 4. 
     What punctuation ends most lines of C code? A. .  B. ;  C. :  D. ' 
  • 5. 
     Which of the following is a correct comment? A. */ Comments */ B. ** Comment ** C. /* Comment */ D. { Comment }
  • 6. 
     Which of the following is not a correct variable type? A. float B. real C. int D. double
  • 7. 
    Which of the following is the correct operator to compare two variables? A. := B. = C. equal D. ==
  • 8. 
     Which of the following is the boolean operator for logical-and? A. & B. && C. | D. |&
  • 9. 
     Evaluate !(1 && !(0 || 1)). A. True B. False C. Unevaluatable
  • 10. 
    Which of the following shows the correct syntax for an if statement? A. if expression B. if { expression C. if ( expression ) D. expression if
  • 11. 
    What is the final value of x when the code int x; for(x=0; x<10; x++) {} is run? A. 10 B. 9 C. 0 D. 1
  • 12. 
    When does the code block following while(x<100) execute? A. When x is less than one hundred B. When x is greater than one hundred C. When x is equal to one hundred D. While it wishes
  • 13. 
    Which is not a loop structure? A. For B. Do while C. While D. Repeat Until
  • 14. 
    How many times is a do-while loop guaranteed to loop? A. 0 B. Infinitely C. 1 D. Variable
  • 15. 
    Which is not a proper prototype? A. int funct(char x, char y); B. double funct(char x) C. void funct(); D. char x();
  • 16. 
    What is the return type of the function with prototype: "int func(char x, float v, double t);" A. char B. int C. float D. double
  • 17. 
     Which of the following is a valid function call (assuming the function exists)? A. funct; B. funct x, y; C. funct(); D. int funct();
  • 18. 
     Which of the following is a complete function? A. int funct(); B. int funct(int x) {return x=x+1;} C. void funct(int) { printf( "Hello");  D. void funct(x) { printf( "Hello"); }
  • 19. 
    Which follows the case statement? A. : B. ; C. - D. A newline
  • 20. 
    What is required to avoid falling through from one case to the next? A. end; B. break; C. Stop; D. A semicolon.
  • 21. 
     What keyword covers unhandled possibilities? A. all B. contingency C. default D. other
  • 22. 
    What is the result of the following code? int x=0;   switch(x)   {     case 1: printf( "One" );     case 0: printf( "Zero" );     case 2: printf( "Hello World" );   }
    • A. One
    • B. Zero
    • C. Hello World
    • D. ZeroHello World
  • 23. 
    Which of the following is a two-dimensional array? A. array anarray[20][20]; B. int anarray[20][20]; C. int array[20, 20]; D. char array[20];
  • 24. 
    Which of the following correctly accesses the seventh element stored in foo, an array with 100 elements? A. foo[6]; B. foo[7]; C. foo(7); D. foo;
  • 25. 
    Which of the following gives the memory address of the first element in array foo, an array with 100 elements? A. foo[0]; B. foo; C. &foo; D. foo[1];
Back to Top Back to top