Which loop is used when the number of iterations is known in advance?
1 Crore+ students have signed up on EduRev. Have you? Download the App |
Which loop is suitable when the condition for termination is checked at the beginning?
What is the output of the following code snippet?
for (int i = 0; i < 5; i++) {
if (i == 3)
break;
cout << i << " ";
}
What is the output of the following code snippet?
int i = 0;
while (i < 5) {
i++;
if (i == 3)
continue;
cout << i << " ";
}
Which loop structure allows the body of the loop to be executed first and then checks the condition?
What is the output of the following code snippet?
int x = 10;
do {
cout << x << " ";
x--;
} while (x > 0);
What is the output of the following code snippet?
for (int i = 0; i < 5; i++) {
cout << i << " ";
}
What is the output of the following code snippet?
int x = 5;
while (x > 0) {
cout << x << " ";
x--;
}
What is the output of the following code snippet?
int x = 5;
do {
cout << x << " ";
x--;
} while (x > 0);
What is the output of the following code snippet?
int i = 1;
while (i <= 5) {
cout << i << " ";
i += 2;
}
What is the output of the following code snippet?
int x = 10;
while (x >= 0) {
if (x % 2 == 0)
cout << x << " ";
x--;
}
What is the output of the following code snippet?
int i = 0;
do {
cout << i << " ";
i++;
} while (i <= 0);
What is the output of the following code snippet?
int i = 10;
while (i > 0) {
cout << i << " ";
i -= 3;
}
What is the output of the following code snippet?
for (int i = 0; i < 5; i += 2) {
cout << i << " ";
}
What is the output of the following code snippet?
int x = 5;
do {
cout << x << " ";
x++;
} while (x < 5);
What is the output of the following code snippet?
int i = 0;
while (i < 5) {
cout << i << " ";
if (i == 2)
break;
i++;
}
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++;
}
}
What is the output of the following code snippet?
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 3; j++) {
cout << i * j << " ";
}
cout << endl;
}
What is the output of the following code snippet?
int x = 2;
while (x <= 8) {
if (x % 2 == 0) {
cout << x << " ";
x += 2;
} else {
x++;
}
}
What is the output of the following code snippet?
int i = 2;
while (i < 8) {
if (i % 2 == 0) {
cout << i << " ";
}
i++;
}
What is the output of the following code snippet?
int i = 1;
while (i < 5) {
if (i == 3) {
i++;
continue;
}
cout << i << " ";
i++;
}
What is the output of the following code snippet?
int i = 1;
while (i < 6) {
if (i % 2 == 0) {
cout << i << " ";
}
i++;
}
What is the output of the following code snippet?
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (i == j)
continue;
cout << i << " " << j << endl;
}
}
What is the output of the following code snippet?
int x = 1;
while (x <= 5) {
if (x % 2 == 0) {
cout << x << " ";
break;
}
x++;
}
What is the output of the following code snippet?
int i = 1;
while (i <= 5) {
if (i % 3 == 0) {
cout << i << " ";
break;
}
i++;
}
What is the output of the following code snippet?
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
if (j == 3)
break;
cout << i << " " << j << endl;
}
}
70 videos|45 docs|15 tests
|
70 videos|45 docs|15 tests
|