+ 1

IF() have only variable???

In c++ when if() statement with variable only (without any comparison to anything else) is implemented what does that check for eg: if(a) cout<<"LIKE IT"; now What is the condition on which if statement will run...

3rd Jan 2017, 4:32 PM
LUV SUREN
LUV SUREN - avatar
6 odpowiedzi
+ 6
the statement in brackets must return true or false (boolean)(true = execute, false = don't) that's why we put conditions there ((1 + 1 == 2) == true) if "a" is true or different than 0 it'll execute else it won't...
3rd Jan 2017, 4:43 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 4
I think so...
3rd Jan 2017, 4:57 PM
Valen.H. ~
Valen.H. ~ - avatar
+ 3
good question 0 is equal to false 1 is equal to true
3rd Jan 2017, 4:44 PM
Kamil
Kamil - avatar
+ 2
in some languages everything higher than 0 is true
3rd Jan 2017, 4:44 PM
Kamil
Kamil - avatar
+ 2
it works for negative values too (-4,-1....) means it returns false for 0 only...??? m i right???
3rd Jan 2017, 4:47 PM
LUV SUREN
LUV SUREN - avatar