C++ MCQ Questions and Answers
C++ MCQ questions and answers are vital for students preparing for software development and IT placement exams like TCS, Infosys, and Tech Mahindra. These questions test your understanding of core concepts such as classes, objects, inheritance, polymorphism, and templates. Practicing C++ programming MCQs with detailed explanations helps strengthen coding logic and syntax understanding. This topic is ideal for candidates aiming to improve their performance in programming interview questions with answers and campus recruitment tests.
C++ MCQ
Showing 10 of
93 questions
71. Observe the following block of code and determine what happens when x=2? switch (x){ case 1: case 2: case 3: cout<< "x is 3, so jumping to third branch"; goto thirdBranch; default: cout<<"x is not within the range, so need to say Thank You!"; }
- Program jumps to the end of switch statement since there is nothing to do for x=2
- The code inside default will run since there is no task for x=2, so, default task is run
- Will display x is 3, so jumping to third branch and jumps to thirdBranch.
- None of above
72. Observe the following block of code and determine what happens when x=2? switch (x){ case 1: case 2: case 3: cout<< "x is 3, so jumping to third branch"; goto thirdBranch; default: cout<<"x is not within the range, so need to say Thank You!"; }
- Program jumps to the end of switch statement since there is nothing to do for x=2
- The code inside default will run since there is no task for x=2, so, default task is run
- Will display x is 3, so jumping to third branch and jumps to thirdBranch.
- None of above
73. Which of the following is false for switch statement in C++?
- It uses labels instead of blocks
- we need to put break statement at the end of the group of statement of a condition
- we can put range for case such as case 1..3
- None of above
74. The void specifier is used if a function does not have return type.
- TRUE
- FALSE
75. You must specify void in parameters if a function does not have any arguments.
- TRUE
- FALSE
77. Study the following piece of code and choose the best answer int x=5, y=3, z; a=addition(x,y)
- The function addition is called by passing the values
- The function addition is called by passing reference
78. In case of arguments passed by values when calling a function such as z=addidion(x,y),
- Any modifications to the variables x & y from inside the function will not have any effect outside the function.
- The variables x and y will be updated when any modification is done in the function
- The variables x and y are passed to the function addition
- None of above are valid.
79. If the type specifier of parameters of a function is followed by an ampersand (&Wink, that function call is
- pass by value
- pass by reference
80. In case of pass by referenc
- The values of those variables are passed to the function so that it can manipulate them
- The location of variable in memory is passed to the function so that it can use the same memory area for its processing
- The function declaration should contain ampersand (&Wink in its type declaration
- All of above