C++ MCQ Questions and Answers

Practice Mode
Showing 10 of 93 questions
Q71
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!";                 }
  • A Program jumps to the end of switch statement since there is nothing to do for x=2
  • B The code inside default will run since there is no task for x=2, so, default task is run
  • C Will display x is 3, so jumping to third branch and jumps to thirdBranch.
  • D None of above
Answer: Option C
Q72
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!";                 }
  • A Program jumps to the end of switch statement since there is nothing to do for x=2
  • B The code inside default will run since there is no task for x=2, so, default task is run
  • C Will display x is 3, so jumping to third branch and jumps to thirdBranch.
  • D None of above
Answer: Option C
Q73
Which of the following is false for switch statement in C++?
  • A It uses labels instead of blocks
  • B we need to put break statement at the end of the group of statement of a condition
  • C we can put range for case such as case 1..3
  • D None of above
Answer: Option C
Q74
The void specifier is used if a function does not have return type.
  • A TRUE
  • B FALSE
Answer: Option A
Q75
You must specify void in parameters if a function does not have any arguments.
  • A TRUE
  • B FALSE
Answer: Option B
Q76
Type specifier is optional when declaring a function
  • A TRUE
  • B FALSE
Answer: Option B
Q77
Study the following piece of code and choose the best answer int x=5, y=3, z; a=addition(x,y)
  • A The function addition is called by passing the values
  • B The function addition is called by passing reference
Answer: Option A
Q78
In case of arguments passed by values when calling a function such as z=addidion(x,y),
  • A Any modifications to the variables x & y from inside the function will not have any effect outside the function.
  • B The variables x and y will be updated when any modification is done in the function
  • C The variables x and y are passed to the function addition
  • D None of above are valid.
Answer: Option A
Q79
If the type specifier of parameters of a function is followed by an ampersand (&Wink, that function call is
  • A pass by value
  • B pass by reference
Answer: Option B
Q80
In case of pass by referenc
  • A The values of those variables are passed to the function so that it can manipulate them
  • B The location of variable in memory is passed to the function so that it can use the same memory area for its processing
  • C The function declaration should contain ampersand (&Wink in its type declaration
  • D All of above
Answer: Option B
Questions and Answers for Competitive Exams Various Entrance Test