All Exams  >   EmSAT Achieve  >   C++ for EmSAT Achieve  >   All Questions

All questions of Loops for EmSAT Achieve Exam

What will be the output of the following code snippet?
for (int i = 1; i <= 3; i++) {
    for (int j = 1; j <= i; j++) {
        cout << i << " ";
    }
}
  • a)
    1 2 2 3 3 3
  • b)
    1 2 3
  • c)
    1 1 2 1 2 3
  • d)
    1 1 1 2 2 3
Correct answer is option 'A'. Can you explain this answer?

Code Explanation
The given code snippet consists of nested loops that output specific values based on the loop indices.
Outer Loop
- The outer loop iterates with `i` taking values from 1 to 3.
- For each value of `i`, the inner loop executes.
Inner Loop
- The inner loop iterates with `j` from 1 to the current value of `i`.
- The inner loop prints the current value of `i` followed by a space.
Iteration Breakdown
- When i = 1:
- The inner loop runs for `j = 1`.
- Output: `1 ` (printed once)
- When i = 2:
- The inner loop runs for `j = 1` and `j = 2`.
- Output: `2 ` (printed twice)
- When i = 3:
- The inner loop runs for `j = 1`, `j = 2`, and `j = 3`.
- Output: `3 ` (printed three times)
Final Output Compilation
Combining all the outputs from each iteration:
- From `i = 1`: `1 `
- From `i = 2`: `2 2 `
- From `i = 3`: `3 3 3 `
Thus, the final printed output is: `1 2 2 3 3 3 `
Conclusion
The correct answer is option 'A': 1 2 2 3 3 3, as it accurately reflects the output of the nested loops in the code snippet.

Which loop construct is most suitable when the number of iterations is known in advance?
  • a)
    while loop
  • b)
    do-while loop
  • c)
    for loop
  • d)
    if-else statement
Correct answer is option 'C'. Can you explain this answer?

Sonal Yadav answered
The for loop is most suitable when the number of iterations is known in advance, as it provides a compact way to specify the initialization, condition, and update expressions in a single line.

Which loop is guaranteed to execute at least once?
  • a)
    for loop
  • b)
    while loop
  • c)
    do-while loop
  • d)
    None of the above
Correct answer is option 'C'. Can you explain this answer?

The Do-while Loop

The do-while loop is the loop guaranteed to execute at least once. It is a control flow statement that allows code to be executed repeatedly based on a given condition. The structure of a do-while loop consists of a block of code enclosed in curly braces, followed by the keyword "do", a set of statements to be executed, and the keyword "while" followed by a condition. The condition is evaluated at the end of the loop, and if it evaluates to true, the loop will repeat.

Structure:
The structure of a do-while loop is as follows:
```
do {
// code to be executed
} while (condition);
```

Execution:
1. The code within the loop is executed first, regardless of the condition.
2. After the code is executed, the condition is checked.
3. If the condition is true, the loop will repeat and the code will be executed again.
4. If the condition is false, the loop will terminate, and the program will continue to the next statement after the loop.

At least one execution:
The key difference between a do-while loop and other loops, such as the for loop and the while loop, is that the do-while loop guarantees the execution of its code block at least once. This is because the condition is evaluated at the end of the loop, meaning the code block will always execute at least once before the condition is checked.

In contrast, a for loop and a while loop check the condition before executing the code block. If the condition is false initially, the loop will not execute at all. This is why the do-while loop is the only loop that is guaranteed to execute at least once.

Use cases:
The do-while loop is often used when we want to ensure that a block of code is executed at least once, regardless of the condition. It is commonly used in situations where we need to take user input or validate input before proceeding with the rest of the program.

Overall, the do-while loop provides flexibility and ensures that a certain code block is executed at least once, making it a valuable tool in programming.

Which loop construct is used when you want to execute a block of code at least once, even if the condition is false initially?
  • a)
    while loop
  • b)
    do-while loop
  • c)
    for loop
  • d)
    if-else statement
Correct answer is option 'B'. Can you explain this answer?

Understanding Loop Constructs
When dealing with loops in programming, the choice of construct depends on the desired execution flow. Among the options given, the do-while loop is specifically designed to ensure that a block of code is executed at least once, regardless of the initial condition.
Key Features of the Do-While Loop
- Guaranteed Execution:
- The code block inside a do-while loop executes once before checking the condition.
- Syntax:
- The basic structure is:
do {
// code block
} while (condition);
- Condition Check:
- The condition is evaluated after the execution of the code block, which means even if the condition is false initially, the block will still run once.
Comparison with Other Constructs
- While Loop:
- This loop checks the condition before the execution of the code block. If the condition is false initially, the code may never run.
- For Loop:
- Similar to the while loop, it evaluates the condition before executing the code block. If the condition is false, no execution occurs.
- If-Else Statement:
- This is a conditional statement that executes the block of code only if the condition is true and does not loop at all.
Conclusion
The do-while loop is ideal for scenarios where you need to ensure that an action occurs at least once, making it distinct from other looping constructs that depend on the condition being true from the start.

What is the output of the following code snippet?
int x = 10;
while (x >= 0) {
    if (x % 2 == 0)
        cout << x << " ";
    x--;
}
  • a)
    10 9 8 7 6 5 4 3 2 1 0
  • b)
    10 8 6 4 2 0
  • c)
    9 7 5 3 1
  • d)
    10 9 8 7 6 5 4 3 2
Correct answer is option 'B'. Can you explain this answer?

Sonal Yadav answered
The loop starts with x equal to 10 and decrements x by 1 on each iteration. The loop continues as long as x is greater than or equal to 0. The loop prints the values of x only when x is even (divisible by 2), resulting in 10 8 6 4 2 0.

What is the output of the following code snippet?
int i = 0;
while (i < 5) {
    i++;
    if (i == 3)
        continue;
    cout << i << " ";
}
  • a)
    1 2 3 4 5
  • b)
    1 2 4 5
  • c)
    0 1 2 3 4
  • d)
    0 1 2 4 5
Correct answer is option 'B'. Can you explain this answer?

Explanation:
The given code snippet initializes a variable i to 0 and then enters a while loop that increments i by 1 in each iteration. If i equals 3, the continue statement is executed, which skips the rest of the loop body and goes to the next iteration.

Details:
- The initial value of i is 0.
- In the first iteration, i is incremented to 1 and printed.
- In the second iteration, i is incremented to 2 and printed.
- In the third iteration, i is incremented to 3. Since i equals 3, the continue statement is executed, skipping the print statement for 3.
- In the fourth iteration, i is incremented to 4 and printed.
- In the fifth iteration, i is incremented to 5 and printed.

Final Output:
- The output of the code snippet is: 1 2 4 5
Therefore, the correct answer is option B - 1 2 4 5.

Which loop construct is best suited when the number of iterations is unknown?
  • a)
    while loop
  • b)
    do-while loop
  • c)
    for loop
  • d)
    if-else statement
Correct answer is option 'A'. Can you explain this answer?

While Loop is Best Suited for Unknown Number of Iterations
While loop is the best choice when the number of iterations is unknown because it repeats a block of code as long as a specified condition is true. Here's why:

Flexibility in Condition Checking
- While loop allows you to check the condition at the beginning of each iteration. This means you can continue iterating as long as the condition remains true, making it ideal for situations where the number of iterations is uncertain.

Dynamic Termination
- Since the condition is checked before each iteration, the loop can dynamically terminate when the condition becomes false. This flexibility is crucial when the exact number of iterations is not predetermined.

Example Scenario
- For instance, if you are reading user input in a program and need to keep prompting the user until a specific input is received, a while loop would be the perfect choice. You can continue looping until the desired input is provided without knowing in advance how many times the loop will run.
In conclusion, while loop is the most suitable loop construct when the number of iterations is unknown due to its flexibility in condition checking and dynamic termination based on the condition. It allows for a more adaptable and efficient way to handle situations where the exact number of iterations is uncertain.

What is the purpose of the initialization expression in a for loop?
  • a)
    To specify the condition for terminating the loop
  • b)
    To update the loop variable after each iteration
  • c)
    To initialize the loop variable before the loop starts
  • d)
    To specify the code to be executed in each iteration
Correct answer is option 'C'. Can you explain this answer?

The Purpose of the Initialization Expression in a For Loop

The initialization expression in a for loop serves the purpose of initializing the loop variable before the loop starts. It is executed only once, at the beginning of the loop, and helps set the initial value of the loop variable.

Explanation:

A for loop is a control flow statement that allows us to execute a block of code repeatedly under certain conditions. It consists of three parts: the initialization expression, the condition, and the increment expression.

The initialization expression is responsible for initializing the loop variable before the loop starts. It is typically used to set the initial value of the loop variable to a specific value. This expression is executed only once, at the beginning of the loop, and it is not required to be present in every for loop.

Example:
Let's consider the following example of a for loop in the C programming language:

```
for (int i = 0; i < 5;="" i++)="" />
printf("%d\n", i);
}
```

In this example, the initialization expression is `int i = 0;`. It initializes the loop variable `i` with the value 0 before the loop starts. This means that the loop will start executing with the initial value of `i` as 0.

Conclusion:

The initialization expression in a for loop is responsible for initializing the loop variable before the loop starts. It is executed only once, at the beginning of the loop, and helps set the initial value of the loop variable. This expression is optional and not required to be present in every for loop.

Which of the following loop constructs is guaranteed to execute at least once?
  • a)
    while loop
  • b)
    do-while loop
  • c)
    for loop
  • d)
    if-else statement
Correct answer is option 'B'. Can you explain this answer?

Sonal Yadav answered
The do-while loop is guaranteed to execute at least once because the condition is checked at the end of the loop. This ensures that the loop body executes at least once before checking the condition.

What will be the output of the following code snippet?
for (int i = 0; i < 5; i++) {
    if (i == 2)
        continue;
    cout << i << " ";
}
  • a)
    0 1 2 3 4
  • b)
    0 1 3 4
  • c)
    0 1 2 3
  • d)
    0 1 3
Correct answer is option 'B'. Can you explain this answer?

The code snippet provided is incomplete and does not specify the condition for the for loop. Therefore, it is not possible to determine the output without additional information.

What will be the output of the following code snippet?
int i = 1;
do {
    cout << i << " ";
    i *= 2;
} while (i <= 5);
  • a)
    1 2 3 4 5
  • b)
    1 2 4
  • c)
    1 2 4 8
  • d)
    1
Correct answer is option 'B'. Can you explain this answer?

The code snippet is incomplete and does not provide the complete expression after "cout". Therefore, it is not possible to determine the output of the code snippet.

What is the output of the following code snippet?
int i = 1;
while (i < 5) {
    if (i == 3) {
        i++;
        continue;
    }
    cout << i << " ";
    i++;
}
  • a)
    1 2 3 4
  • b)
    1 2 3 4 5
  • c)
    1 2 4
  • d)
    1 3 4
Correct answer is option 'C'. Can you explain this answer?

Sonal Yadav answered
The loop starts with i equal to 1. If i is equal to 3, i is incremented by 1 using the continue statement. Otherwise, i is printed, and i is incremented by 1. The loop continues as long as i is less than 5. Therefore, the output is 1 2 4.

What is the purpose of the continue statement in a loop?
  • a)
    To terminate the loop and skip the remaining iterations
  • b)
    To skip the current iteration and continue with the next iteration
  • c)
    To exit the program completely
  • d)
    To execute a different block of code
Correct answer is option 'B'. Can you explain this answer?


Explanation:

Purpose of the continue statement in a loop:

The continue statement in a loop is used to skip the current iteration and continue with the next iteration. It allows the program to bypass certain parts of the loop's code block based on a specific condition without terminating the loop entirely.

How the continue statement works:

- When the continue statement is encountered in a loop, it immediately stops the execution of the current iteration.
- The program then proceeds to evaluate the loop condition and starts the next iteration if the condition is met.
- This allows the loop to continue running while skipping over the specific block of code associated with the continue statement.

Example scenario:

For instance, in a loop that iterates over a list of numbers, you can use a continue statement to skip over even numbers and only process odd numbers. This can help optimize the loop by avoiding unnecessary computations for certain elements.

Benefits of using the continue statement:

- Increases the efficiency of the loop by skipping unnecessary iterations.
- Allows for more precise control over the flow of the loop.
- Helps in avoiding redundant or unwanted operations within the loop.

By understanding the purpose and functionality of the continue statement in a loop, programmers can write more efficient and structured code that meets the specific requirements of their algorithms.

What will be the output of the following code snippet?
int x = 10;
while (x > 0) {
    x--;
    if (x % 3 == 0)
        continue;
    cout << x << " ";
}
  • a)
    9 8 7 5 4 2 1
  • b)
    10 9 8 7 6 5 4 3 2 1
  • c)
    9 8 7 6 5 4 2 1
  • d)
    10 9 8 7 5 4 2 1
Correct answer is option 'C'. Can you explain this answer?

The code snippet is incomplete and lacks a condition in the while loop. Without a condition, the loop will run indefinitely, causing an infinite loop. Therefore, it is not possible to determine the output of the code snippet without knowing the condition.

What will be the output of the following code snippet?
int x = 5;
while (x > 0) {
    cout << x << " ";
    x--;
}
  • a)
    5 4 3 2 1
  • b)
    5
  • c)
    1 2 3 4 5
  • d)
    1
Correct answer is option 'A'. Can you explain this answer?

This code snippet will result in a syntax error because the while loop condition is not complete. The condition `x` is not being compared to anything. To fix this error, the condition should be completed with a comparison, for example:

```java
int x = 5;
while (x > 0) {
System.out.println(x);
x--;
}
```

This will output:

```
5
4
3
2
1
```

What is the output of the following code snippet?
int x = 5;
do {
    cout << x << " ";
    x--;
} while (x > 0);
  • a)
    5 4 3 2 1
  • b)
    1 2 3 4 5
  • c)
    0 1 2 3 4
  • d)
    4 3 2 1 0
Correct answer is option 'A'. Can you explain this answer?

Sonal Yadav answered
The loop starts with x equal to 5 and prints its value. Then, x is decremented by 1, and the loop continues as long as x is greater than 0. The loop prints the values of x on each iteration, resulting in 5 4 3 2 1.

What will be the output of the following code snippet?
int n = 0;
while (n < 5) {
    cout << n << " ";
    n++;
    if (n == 3)
        break;
}
  • a)
    0 1 2
  • b)
    0 1 2 3 4
  • c)
    0 1
  • d)
    0 1 2 3
Correct answer is option 'A'. Can you explain this answer?

Sonal Yadav answered
The while loop iterates as long as n is less than 5. In each iteration, the value of n is printed, and then it is incremented by 1. The loop breaks when n becomes 3 due to the break statement.

Which loop structure allows the body of the loop to be executed first and then checks the condition?
  • a)
    for loop
  • b)
    while loop
  • c)
    do-while loop
  • d)
    None of the above
Correct answer is option 'C'. Can you explain this answer?

Sonal Yadav answered
The do-while loop allows the body of the loop to be executed first and then checks the condition. If the condition is true, the loop continues; otherwise, it terminates.

What is the output of the following code snippet?
int i = 0;
do {
    cout << i << " ";
    i++;
} while (i <= 0);
  • a)
    0
  • b)
    0 1
  • c)
    1
  • d)
    The code will result in an infinite loop.
Correct answer is option 'A'. Can you explain this answer?

Sonal Yadav answered
The loop starts with i equal to 0 and prints its value. Then, i is incremented by 1. Since the condition i <= 0 is not satisfied, the loop terminates. Therefore, the output is 0.

What will be the output of the following code snippet?
for (int i = 0; i < 5; i++) {
    for (int j = 0; j < 3; j++) {
        if (j == 1)
            continue;
        cout << i + j << " ";
    }
}
  • a)
    1 2 3 3 4 5 5 6 7 7 8 9
  • b)
    0 1 2 3 4 5 6 7 8 9
  • c)
    0 1 3 4 6 7
  • d)
    1 2 3 4 5 6 7 8 9 10
Correct answer is option 'C'. Can you explain this answer?

Sonal Yadav answered
The outer for loop iterates over the values of i from 0 to 4. The inner for loop iterates over the values of j from 0 to 2. In each iteration, the sum of i and j is printed, except when j is equal to 1 due to the continue statement. The loop prints the values 0, 1, 3, 4, 6, and 7.

What will be the output of the following code snippet?
int i = 0;
do {
    cout << i << " ";
    i++;
} while (i < 5);
  • a)
    0 1 2 3 4
  • b)
    0 1 2 3
  • c)
    1 2 3 4 5
  • d)
    1 2 3 4
Correct answer is option 'A'. Can you explain this answer?

Sonal Yadav answered
The do-while loop iterates as long as i is less than 5. In each iteration, the value of i is printed, and then it is incremented by 1. The loop prints the values 0, 1, 2, 3, and 4.

What will be the output of the following code snippet?
int i = 0;
do {
    cout << i << " ";
    i++;
} while (i < 5);
  • a)
    0 1 2 3 4
  • b)
    0 1 2 3
  • c)
    0 1 2 3 4 5
  • d)
    1 2 3 4
Correct answer is option 'A'. Can you explain this answer?

Sonal Yadav answered
The do-while loop iterates as long as i is less than 5. In each iteration, the value of i is printed, and then it is incremented by 1. The loop prints the values 0, 1, 2, 3, and 4.

What will be the output of the following code snippet?
int i = 0;
while (i < 3) {
    for (int j = 0; j < 2; j++) {
        cout << i + j << " ";
        if (i + j == 2)
            break;
    }
    i++;
}
  • a)
    0 1 1 2
  • b)
    0 1 2 3
  • c)
    1 2 2 3
  • d)
    0 1 2
Correct answer is option 'D'. Can you explain this answer?

Sonal Yadav answered
The while loop iterates as long as i is less than 3. In each iteration, the value of i is printed, and then the inner for loop iterates over the values of j from 0 to 1. The sum of i and j is printed in each inner loop iteration. The loop prints the values 0, 1, 2.

Which loop construct is used to read an unknown number of inputs until a certain condition is met?
  • a)
    while loop
  • b)
    do-while loop
  • c)
    for loop
  • d)
    if-else statement
Correct answer is option 'A'. Can you explain this answer?

Sonal Yadav answered
The while loop is commonly used to read an unknown number of inputs until a certain condition is met. The loop continues to execute as long as the condition specified in the loop header remains true.

What will be the output of the following code snippet?
int x = 2;
while (x <= 10) {
    cout << x << " ";
    x += 3;
}
  • a)
    2 5 8
  • b)
    2 3 4 5 6 7 8 9 10
  • c)
    2 5 9
  • d)
    2 5 8 11
Correct answer is option 'A'. Can you explain this answer?

Sonal Yadav answered
The while loop iterates as long as x is less than or equal to 10. In each iteration, the value of x is printed, and then it is incremented by 3. The loop prints the values 2, 5, and 8.

What is the output of the following code snippet?
int i = 1;
while (i < 6) {
    if (i % 2 == 0) {
        cout << i << " ";
        i += 2;
    } else {
        i++;
    }
}
  • a)
    2 4 6
  • b)
    2 4
  • c)
    1 3 5
  • d)
    1 2 3 4 5
Correct answer is option 'B'. Can you explain this answer?

Sonal Yadav answered
The loop starts with i equal to 1. If i is divisible by 2 (i.e., even), it is printed, and i is incremented by 2. Otherwise, i is incremented by 1. The loop continues as long as i is less than 6. Therefore, the output is 2 4.

Which loop is suitable when the condition for termination is checked at the beginning?
  • a)
    for loop
  • b)
    while loop
  • c)
    do-while loop
  • d)
    None of the above
Correct answer is option 'C'. Can you explain this answer?

Sonal Yadav answered
The do-while loop is suitable when the condition for termination is checked at the end. This ensures that the loop body is executed at least once before the condition is evaluated.

What is the output of the following code snippet?
int x = 5;
while (x > 0) {
    cout << x << " ";
    x--;
}
  • a)
    5 4 3 2 1
  • b)
    1 2 3 4 5
  • c)
    0 1 2 3 4
  • d)
    4 3 2 1 0
Correct answer is option 'A'. Can you explain this answer?

Sonal Yadav answered
The loop starts with x equal to 5 and prints its value. Then, x is decremented by 1, and the loop continues as long as x is greater than 0. The loop prints the values of x on each iteration, resulting in 5 4 3 2 1.

What will be the output of the following code snippet?
int i = 1;
do {
    cout << i << " ";
    i *= 3;
} while (i <= 10);
  • a)
    1 2 3 4 5 6 7 8 9 10
  • b)
    1 3 9
  • c)
    1 3 6 9
  • d)
    1 3 6
Correct answer is option 'B'. Can you explain this answer?

Sonal Yadav answered
The do-while loop is executed as long as i is less than or equal to 10. In each iteration, the value of i is printed, and then it is multiplied by 3. The loop prints the values 1, 3, and 9.

What is the output of the following code snippet?
int x = 5;
do {
    cout << x << " ";
    x++;
} while (x < 5);
  • a)
    5
  • b)
    5 6
  • c)
    The code will result in an infinite loop.
  • d)
    The code will not output anything.
Correct answer is option 'C'. Can you explain this answer?

Sonal Yadav answered
The condition x < 5 in the do-while loop is always true because x starts at 5 and is incremented on each iteration. Therefore, the loop will continue indefinitely, resulting in an infinite loop.

What will be the output of the following code snippet?
int i = 1;
while (i <= 5) {
    cout << i << " ";
    i += 2;
}
  • a)
    1 2 3 4 5
  • b)
    1 3 5
  • c)
    2 4
  • d)
    2 4 6
Correct answer is option 'B'. Can you explain this answer?

Sonal Yadav answered
The while loop iterates as long as i is less than or equal to 5. In each iteration, the value of i is printed, and then it is incremented by 2. The loop prints the odd numbers from 1 to 5.

What will be the output of the following code snippet?
int n = 0;
while (n < 5) {
    cout << n << " ";
    if (n == 2)
        break;
    n++;
}
  • a)
    0 1 2
  • b)
    0 1 2 3 4
  • c)
    0 1 2 3
  • d)
    0 1 2 3 4 5
Correct answer is option 'C'. Can you explain this answer?

Sonal Yadav answered
The while loop iterates as long as n is less than 5. In each iteration, the value of n is printed, and then it is incremented by 1. The loop breaks when n becomes 2 due to the break statement. The loop prints the values 0, 1, 2, and 3.

Which loop is used when the number of iterations is known in advance?
  • a)
    for loop
  • b)
    while loop
  • c)
    do-while loop
  • d)
    None of the above
Correct answer is option 'A'. Can you explain this answer?

Sonal Yadav answered
The for loop is used when the number of iterations is known in advance. It consists of three parts: initialization, condition, and increment/decrement. The loop body executes until the condition becomes false.

What will be the output of the following code snippet?
int n = 3;
do {
    cout << n << " ";
    n--;
} while (n > 0);
  • a)
    3 2 1
  • b)
    3 2 1 0
  • c)
    1 2 3
  • d)
    1 2 3 0
Correct answer is option 'A'. Can you explain this answer?

Sonal Yadav answered
The do-while loop is executed at least once because the condition n > 0 is checked at the end of the loop. In each iteration, the value of n is printed, and then it is decremented by 1. The loop continues until n becomes 0.

What will be the output of the following code snippet?
for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 2; j++) {
        cout << i + j << " ";
    }
}
  • a)
    0 1 1 2 2 3
  • b)
    0 1 2 3 4 5
  • c)
    1 2 3 4 5 6
  • d)
    1 2 2 3 3 4
Correct answer is option 'A'. Can you explain this answer?

Sonal Yadav answered
The outer for loop iterates over the values of i from 0 to 2. The inner for loop iterates over the values of j from 0 to 1. In each iteration, the sum of i and j is printed. The loop prints the values 0, 1, 1, 2, 2, 3.

What is the output of the following code snippet?
int i = 1;
while (i <= 5) {
    cout << i << " ";
    i += 2;
}
  • a)
    1 2 3 4 5
  • b)
    1 3 5
  • c)
    2 4 6
  • d)
    1 3
Correct answer is option 'B'. Can you explain this answer?

Sonal Yadav answered
The loop starts with i equal to 1 and increments i by 2 on each iteration. The loop continues as long as i is less than or equal to 5. The output is 1 3 5.

What is the output of the following code snippet?
int i = 2;
while (i < 8) {
    if (i % 2 == 0) {
        cout << i << " ";
    }
    i++;
}
  • a)
    2 4 6
  • b)
    2 4 6 8
  • c)
    2 4 6 8 10
  • d)
    4 6 8
Correct answer is option 'A'. Can you explain this answer?

Sonal Yadav answered
The loop starts with i equal to 2. If i is divisible by 2 (i.e., even), it is printed. i is then incremented by 1. The loop continues as long as i is less than 8. Therefore, the output is 2 4 6.

What is an infinite loop?
  • a)
    A loop that executes a fixed number of times
  • b)
    A loop that executes an unknown number of times
  • c)
    A loop that never terminates
  • d)
    A loop that only executes once
Correct answer is option 'C'. Can you explain this answer?

Sonal Yadav answered
An infinite loop is a loop that never terminates. It keeps executing indefinitely unless interrupted by an external factor, such as a break statement or a condition that causes the loop to terminate.

Chapter doubts & questions for Loops - C++ for EmSAT Achieve 2025 is part of EmSAT Achieve exam preparation. The chapters have been prepared according to the EmSAT Achieve exam syllabus. The Chapter doubts & questions, notes, tests & MCQs are made for EmSAT Achieve 2025 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests here.

Chapter doubts & questions of Loops - C++ for EmSAT Achieve in English & Hindi are available as part of EmSAT Achieve exam. Download more important topics, notes, lectures and mock test series for EmSAT Achieve Exam by signing up for free.

C++ for EmSAT Achieve

71 videos|45 docs|15 tests

Top Courses EmSAT Achieve