C++ Loop Important MCQs

C++ is a powerful and versatile programming language widely used for developing various applications, from system software to game development. One of the fundamental concepts in C++ programming is the use of loops, which allow developers to execute a block of code repeatedly. Understanding loops is crucial for writing efficient and effective programs. This article focuses on C++ Loop Important MCQs, providing a comprehensive set of multiple-choice questions to test your knowledge of loops in C++. Whether you’re a beginner or an experienced programmer, these MCQs will help you grasp the nuances of C++ Loops.

C++ Loop Important MCQs

Q. Which Loop is Faster in C++?

(a) For
(b) While
(c) Do While
(d) All work at same speed

(d) All work at same speed

Q. Size of a Turbo C/C++ Compiler is?

(a) 16 Bit
(b) 32 Bit
(c) 64 Bit
(d) None

(a) 16 Bit

Q. ASCII Value of ‘\0’ Character is?

(a) 0
(b) 48
(c) 32
(d) 65

(a) 0

Q. Which of the following is a formate String?

(a) \n
(b) &
(c) %d
(d) none

(c) %d

Q. Do While Loop is a also known as ______.

(a) Entry Control
(b) Per Tested
(c) Exit Control
(d) All of Above

(c) Exit Control

Q. What is the Ranged of Signed Char?

(a) 0 to 255
(b) -128 to 127
(c) 127 to -128
(d) 0 to 127

(b) -128 to 127

Q. What is the size of Following Struct(Turbo C++ 16 Bit Compiler)?

Syntax :


Struct
{
int a;
char b;
float c;
}

(a) 2 Bytes
(b) 4 Bytes
(c) 10 Bytes
(d) 7 Bytes

(d) 7 Bytes
In Struct you can add all the bytes

Q. Whic of the following is Logical AND Operator?

(a) ||
(b) &
(c) &&
(d) !

(c) &&

Q. Which of the following is a subscript operator?

(a) *
(b) {}
(c) []
(d) ()

(c) [] they used in Array

Q. Which loop is guaranteed to execute at-least once?

(a) for loop
(b) while loop
(c) do-while loop
(d) None

(c) do-while loop

Q. 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) 42
(c) 46
(d) 78

(a) 543

Q. how are many sequences of statements present in c++?

(a) 1
(b) 4
(c) 5
(d) 8

(c) 5

Q. Decision Control statements in C++ can be implemented using?

(a) if
(b) if-else
(c) Conditional Operator
(d) All of the above

(d) All of the above

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

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

if (0) {
cout << "Hello";
}
else
{
cout << "Good Bye";
}
return 0;
}

(a) Hello
(b) HelloGood by
(c) Good Bye
(d) Compilation Error

(c) Good Bye

Q. what is correct syntax of for loop in c++?

(a)

for (statement 1; statement 2; statement 3) {
// code block to be executed
}

(b)

for (statement 1; statement 2; statement 3) {
// code block to be executed
}

(c)

for (statement 1, statement 2, statement 3) {
// code block to be executed
}

(d)

for (statement 1: statement 2: statement 3) {
// code block to be executed
}

(a)

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

(a) Addition operator
(b) Multiplicative operator
(c) Conditional operator
(d) Bitwise operator

(c) Conditional operator

Q. how many minimum number of functions should be present in a c++ program for its execution?

(a) 0
(b) 1
(c) 2
(d) 3

(b) 1

Q. What is the correct Syntax of do while loop?

(a)

do {
// code block to be executed
}
while (condition);

(b)

do(condition) {
// code block to be executed
}
while;

(c)

while {
// code block to be executed
}
do (condition);

(d)

do {
// code block to be executed

while (condition)
};

(a)

Q. What will be the output of the following code?

#include <iostream>

using namespace std;

int main() {
for (int i = 1; i <= 5; ++i) {
cout << i << " ";
}
return 0;
}

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

(b) 1 2 3 4 5

Q. How are many sequences of statements present in c++?

(a) 1
(b) 2
(c) 4
(d) 5

(d) 5

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

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

(c) 3 (while loop,for loop, do while loop)

Q. The break statement in repetition structure causes a program to

(a) Again start the loop from 1
(b) All of them
(c) Terminate
(d) Immediately exit

(d) Immediately exit

Q. Loop is used for ___________.

(a) Selection
(b) Decision
(c) Repetition
(d) None of these

(c) Repetition

Q. Which of the following is NOT a loop?

(a) for
(b) while
(c) do while
(d) while do

(d) while do

Q. Which of the loop is also called counter loop?

(a) for
(b) do while
(c) while
(d) All of these

(a) for

Q. One execution of the loop is known as a/an?

(a) Test
(b) Iteration
(c) Repeated
(d) All of these

(b) Iteration

Q. The loop which never ends is called ______.

(a) Counter Loop
(b) Infinite Loop
(c) Nested Loop
(d) None of these

(b) Infinite Loop

Q. The for loop contains _________ expressions.

(a) 3
(b) 4
(c) 7
(d) 9

(a) 3

Q. A for loop contains three expression: initialization, condition, and _______.

(a) Increment
(b) Decrement
(c) Increment/Decrement
(d) Validat

(c) Increment/Decrement

Q. It is the simplest loop in c++ langauge?

(a) for loop
(b) while loop
(c) do while
(d) Nested Loop

(a) for loop

Q. Which of the following loop is called entry controlled loop?

(a) for loop
(b) while loop
(c) do while
(d) None

(b) while loop

Q. Which of the following is pre tested loop in c++?

(a) for loop
(b) while loop
(c) do while
(d) Nested Loop

(b) while loop

Q. Which of the following is post tested loop in c++?

(a) for loop
(b) while loop
(c) do while loop
(d) None of these

(c) do while loop

Q. In which loop the condition comes before the body of the loop?

(a) for loop
(b) while loop
(c) do while loop
(d) Nested Loop

(b) while loop

Q. In which loop the condition comes after the body of the loop.

(a) for loop
(b) while loop
(c) do while loop
(d) Nested Loop

(c) do while loop

Q. Semicolon is placed at the end of condition in ___________.

(a) for loop
(b) while loop
(c) do while loop
(d) Nested Loop

(c) do while loop

Q. A loop within a loop is called __________ loop.

(a) for loop
(b) while loop
(c) do while loop
(d) Nested Loop

(c) do while loop

Q. The statements within curly braces in a loop is known as _____________.

(a) Statement
(b) Part
(c) Body
(d) All of these

(c) Body

Q. What is correct syntax of for loop?

(a) for(initialization:condition:increment/decrement);
(b) for(initialization:condition:increment/decrement)
(c) for(initialization; condition;increment/decrement)
(d) for(initialization;condition;increment/decrement);

(c) for(initialization; condition;increment/decrement)

Q. Which of the ends multiple Statements while loop?

(a) Semicolon (;)
(b) Right Brace
(c) Right Bracket
(d) All of these

(b) Right Brace

Q. What is correct syntax of do while loop?

(a) do{ body of loop} while(condition)
(b) do{ body of loop} while(condition);
(c) do{ body of loop} while(condition):
(d) while{ body of loop } do(condition);

(b) do{ body of loop} while(condition);

Q. What is correct syntax of while loop?

(a) while (condition) [ body of loop ]
(b) while { body of loop }
(c) while (condition) { body of loop }
(d) while (condition); { body of loop }

(c) while (condition) { body of loop }

Q. for, while and do is the _______.

(a) Variable
(b) Data Type
(c) Keywords
(d) All of these

(c) Keywords

Q. Which is the correct ?

(a) for(int i = 0: i<=10: i++)
(b) for(int i = 0; i<=10; i++)
(c) for(int i = 0; i<=10; i++);
(d) for(int i = 0, i<=10; i++)

(b) for(int i = 0; i<=10; i++)

Q. If you want a user to enter exactly 50 values, which loop would be best to use?

(a) for Loop
(b) while Loop
(c) do while Loop
(d) All of these

(a) for Loop

Q. You can never use addresss of ______ variable ?

(a) Global
(b) Static
(c) Auto
(d) Register

(d) Register

Q. The default Storage for local Variables is?

(a) Extren
(b) Static
(c) Auto
(d) Register

(c) Auto

Q. How many times will “Hello, World” be printed in the below program?

#include <stdio.h>
int main(){
int i = 1024;
for(; i; i >>=1){
printf("Hello, World");
return 0;
}
}

(a) 10
(b) 11
(c) Infinite
(d) Compile time Error

(b) 11

Conclusion

Mastering loops is essential for any C++ programmer, as they form the backbone of repetitive tasks in programming. This article on C++ Loop Important MCQs has covered a wide range of questions, from basic syntax to advanced concepts, ensuring a thorough understanding of loops in C++. By practicing these MCQs, you can identify areas for improvement and solidify your knowledge. Whether you’re preparing for an exam or aiming to write more efficient code, these questions serve as a valuable resource. Keep practicing and exploring the intricacies of C++ loops to become a more proficient and confident programmer.