+ 1

why do we have double statements of these if (age > 14) { if(age >= 18)

need explanation

22nd Dec 2016, 2:55 PM
Arjan
Arjan - avatar
4 RĂ©ponses
+ 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
5th Jan 2017, 3:10 PM
nandakishore
nandakishore - avatar
+ 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.
22nd Dec 2016, 4:28 PM
Hatsy Rei
Hatsy Rei - avatar
0
I would say he is correct
1st Jan 2017, 4:01 PM
Tails Ex Machina
Tails Ex Machina - avatar
0
we have to use the nested loop concept by using multiple braces in the loop.
8th Feb 2017, 1:04 PM
Shubham Pareek
Shubham Pareek - avatar