+ 1
why do we have double statements of these if (age > 14) { if(age >= 18)
need explanation
4 Antworten
+ 7
see.if age is greater than 14 , then it will run if{age>=18}
if it is greater or equal to 18 the the output will be adult
otherwise it will run the function in else
+ 6
I believe this is a case of nested if statements.
E.g.
if (age > 14)
{
cout << age;
if (age >= 18)
{
cout << "Adult";
}
}
As we can see here in the above code, if age is 17, only age will be printed. If age is 18 and above, the age will be printed and "Adult" will also be printed. This means that the numerical value of age is checked by a second conditional statement nested within the first conditional statement.
0
I would say he is correct
0
we have to use the nested loop concept by using multiple braces in the loop.