Loading...

C++ Multiple Choice Questions

Our C++ questions and answers focuses on all areas of C++ programming language covering 100+ topics in C++

C++ Decision making & Loops MCQ | Set 3

C++ Decision making & Loops | Set 3


21. The destination statement for the goto label is identified by what label?

a) $
b) @
c) *
d) :



22. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
    int n ;
    for (n = 5; n < 0; n--) 
    {
        cout << n;
        if (n == 3) 
        break;
    }
    return 0;
}

a) 543
b) 54
c) 5432
d) 53



23. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
    int a = 10;
    if (a = 15) 
    {
        time;
        cout << a;
        if (n == 3) 
        goto time;
    }
    break;

    return 0;
}

a) 1010
b) 10
c) infinitely print 10
d) compile time error



24. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
    int n = 15;
    for (; ;) 
    cout << n;
    return 0;
}

a) error
b) 15
c) infinite times of printing n
d) none of the mentioned



25. What will be the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
    int i ;
    for (i = 0; i < 10; i++);
    {
        cout << i;
    }
    return 0;
}

a) 0123456789
b) 10
c) 012345678910
d) compile time error



26. How many types of loops are there in C++?

a) 4
b) 2
c) 3
d) 1



27. Which looping process is best used when the number of iterations is known?

a) While loop
b) For loop
c) Do while loop
d) all looping processes require that the iterations be known



28. Which of the following must be present in switch construct?

a) Expression in ( ) after switch
b) default
c) case followed by value
d) All of the above



29. What is the effect of writing a break statement inside a loop?

a) It cancels remaining iterations.
b) It skips a particular iteration.
c) The program terminates immediately.
d) Loop counter is reset.



30. The break statement causes an exit

a) fromthe innermost loop only.
b) only from the innermost switch.
c) from all loops & switches.
d) from the innermost loop or switch.



- Related Topics