Which loop construct is most suitable when the number of iterations is known in advance?
1 Crore+ students have signed up on EduRev. Have you? Download the App |
Which of the following loop constructs is guaranteed to execute at least once?
Which loop construct is best suited when the number of iterations is unknown?
Which loop construct is used to read an unknown number of inputs until a certain condition is met?
What is the purpose of the initialization expression in a for loop?
Which loop construct is used when you want to execute a block of code at least once, even if the condition is false initially?
What will be the output of the following code snippet?
int x = 5;
while (x > 0) {
cout << x << " ";
x--;
}
What will be the output of the following code snippet?
for (int i = 0; i < 5; i++) {
if (i == 2)
continue;
cout << i << " ";
}
What will be the output of the following code snippet?
int n = 3;
do {
cout << n << " ";
n--;
} while (n > 0);
What will be the output of the following code snippet?
int i = 1;
while (i <= 5) {
cout << i << " ";
i += 2;
}
What will be the output of the following code snippet?
int i = 1;
do {
cout << i << " ";
i *= 2;
} while (i <= 5);
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 << " ";
}
}
What will be the output of the following code snippet?
int x = 10;
while (x > 0) {
x -= 3;
if (x % 2 == 0)
continue;
cout << x << " ";
}
What will be the output of the following code snippet?
int i = 5;
do {
cout << i << " ";
i--;
} while (i > 0);
What will be the output of the following code snippet?
int n = 0;
while (n < 5) {
cout << n << " ";
n++;
if (n == 3)
break;
}
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 << " ";
}
}
What will be the output of the following code snippet?
int x = 5;
while (x > 0) {
x--;
}
cout << x;
What will be the output of the following code snippet?
int x = 2;
while (x <= 10) {
cout << x << " ";
x += 3;
}
What will be the output of the following code snippet?
int i = 1;
do {
cout << i << " ";
i *= 3;
} while (i <= 10);
What will be the output of the following code snippet?
int x = 5;
while (x > 0) {
x--;
if (x == 2)
break;
cout << x << " ";
}
What will be the output of the following code snippet?
int i = 0;
do {
cout << i << " ";
i++;
} while (i < 5);
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 << " ";
}
}
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++;
}
What will be the output of the following code snippet?
int x = 10;
while (x > 0) {
x--;
if (x % 3 == 0)
continue;
cout << x << " ";
}
What will be the output of the following code snippet?
int i = 0;
do {
cout << i << " ";
i++;
} while (i < 5);
What will be the output of the following code snippet?
int n = 0;
while (n < 5) {
cout << n << " ";
if (n == 2)
break;
n++;
}
70 videos|45 docs|15 tests
|
70 videos|45 docs|15 tests
|