Long Quiz 01 19 23

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

1. How many sequences of statements present in C++?

A. 4
B. 3
C. 5
D. 6

2. Decision Control statements in C++ can be implemented using


A. If
B. if-else
C. Conditional Operator
D. All the above

3. What will be the output of the following C++ code?


#include <iostream>
using namespace std;
int main() {

if (0) {
cout << "Hello" ;
}
else
{
cout << "Goodbye" ;
}
return 0;
}
A. Hello
B. Goodbye
C. HelloGood bye
D. Compilation Error

4. if you must make decision based on multiple choices, which of the following is best suited?
A. If
B. if-else
C. if-else-if
D. All the above
E.
5. Can we use string inside switch statement?
A. Yes
B. No

6. In situations where we need to execute body of the loop before testing the condition, we should use_____.
A. For loop
B. While loop
C. Do-while loop
D. Nested for loop

7. Loops in C++ Language are implemented using?


A. While loop
B. For loop
C. Do while loop
D. All the above
8. While loop is faster in C++ Language, for, while or do-while?
A. For
B. While
C. Do-while
D. All work ate same speed

9. What is the way to suddenly come out of or quit any loop in C++?
A. continue; statement
B. break; statement
C. leave; statement
D. quit; statement

10. Which of the following can replace a simple if -wlsw construct?


A. Ternary operator
B. while loop
C. do-while loop
D. fop loop

11. The if...else statement can be replaced by which operator?


A. Bitwise operator
B. Conditional operator
C. Multiplicative operator
D. Addition operator

12. The switch statement is also called as?


A. choosing structure
B. selective structure
C. certain structure
D. bitwise structure

13. Choose a correct C++ for loop syntax.


A. for(initalization; condition; inc/dec){ // statements };
B. for(declaration; condition; incrementoperation){ // statements };
C. for(declaration; incrementoperation; condition){ // statements };
D. for(initalization; condition; incrementoperation){ // statements };

14. Choose a correct C++ do while syntax.


A. dowhile(condition){ // statements };
B. do while(condition){ // statements };
C. do{ // statements }while(condition)
D. do{ // statements }while(condition);

15. Choose a correct C++ Statement.


A. a++ is (a= a+1) POST INCREMENT operator
B. a-- is (a = a-1) POST DECREMENT operator. --a is (a = a-1) PRE DECREMENT operator
C. ++a is (a = a+1) PRE INCREMENT operator
D. All the above.

16. Which of the following is an entry-controlled loop?


A. For loop
B. while loop
C. do-while loop
D. both b & c
17. Which of the following is an exit-controlled loop?
A. While loop
B. For loop
C. Do while loop
D. both b & c

18. Which of the following is most suitable for a menu-dricen program?


A. For
B. While
C. do-while
D. All the above

19. Consider the following loop: for(int i = 0; i<5; i++);


A. It will give compilation error.
B. 5
C. 6
D. Some Garbage value

20. A switch construct can be used with which of the following types of variables?
A. Int
B. int, char
C. int, float, char
D. Any basic datatype

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

You might also like