+ 2

What is if and else in program?

if(a%2==0) { cout<<"no is even."; } else cout<<"no is odd": here what is if and else. function any object etc.?

9th May 2017, 12:26 PM
Rajesh Kumar (Rj)
Rajesh Kumar (Rj) - avatar
3 ответов
+ 8
'if' and 'else' are identifiers which tells the program to evaluate specified conditions.
9th May 2017, 12:28 PM
Hatsy Rei
Hatsy Rei - avatar
+ 1
ok thanks
9th May 2017, 12:29 PM
Rajesh Kumar (Rj)
Rajesh Kumar (Rj) - avatar
+ 1
if and else is using when you have more than 1 condition example for your code in upper : if a%=2 % is modulus and a is variable so when you input 2, and finally a is 2, 2 modulus 2 = 0. then you can see that is even, but if you input 3, and finally a is 3, 3 modulus 2 = 1. then you can see that is odd and if you have more than 2 condition, its called "nested if" example : if fruits=mango print "mango" if "mango" run=true else if fruits=apple print "apple" else print "no input"
9th May 2017, 4:47 PM
Agung Ramadhan Putra
Agung Ramadhan Putra - avatar