loop
1).Which of the following is the correct syntax for an `if` statement in C++?
2).Which of the following is the correct syntax to declare a `while` loop in C++?
3).What is the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
for (int i = 0; i < 3; i++) {
cout << i << " ";
}
return 0;
}
4).What is the purpose of the `break` statement in C++?
5).Which loop is guaranteed to execute at least once in C++?
6).What is the correct syntax for a `switch` statement in C++?
7).In which scenario would you use a `continue` statement in C++?
8).What is the output of the following C++ code?
#include <iostream>
using namespace std;
int main() {
for (int i = 0; i < 4; i++) {
cout << i << " ";
}
return 0;
}
9).What will be printed if the following C++ code is executed?
#include <iostream>
using namespace std;
int main() {
int x = 10;
if (x < 5) {
cout << "Less than 5";
} else if (x > 5) {
cout << "Greater than 5";
} else {
cout << "Equal to 10";
}
return 0;
}