0
are there "if" "then" lines and if so then what are they
"if" "then" statements
3 Réponses
+ 1
there is, but the {} is used for the word "then"
+ 1
There are not if then lines but there are if else lines. After the first part of an if statement you can put an else statement which runs if the if statement is false. There are also else if statements which will run if the their statement is true but the if statement isn't. For example:
if (a==b) {
cout << "A and B are equal";
}
else if (a < b) {
cout << "A is less than B";
}
else {
cout << "B is less than A";
}
0
I'm am confused what you mean.
If a condition is true, then run a certain bit of code?
If so, it's literally just an if statement:
int a = 5;
if (a == 5)
std::cout << "a is 5";
else
std::cout << "a is not 5";