The if Statement What is True & false | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
+ 1

The if Statement What is True & false

I am a little confused on what False & True mean when using integers & Relational Operators like "== & ,<=". What is the difference if the statement is True from false & vice versa. As well as how does it pertain to the value? I guess im trying to say, what difference does it make if the statement is True or False, and how is it relative to what will appear as the out put?

3rd Aug 2017, 12:16 AM
Morris House III
Morris House III - avatar
6 Respuestas
+ 5
@Morris, Your discovery might not be so helpful since at some point you will find that "if" comes with as many other "if"s as you require and finally an "else". It would be better if you understood the concept instead. Jay's first response should be taken seriously. Here's some code to guide you through the maze.👇 https://code.sololearn.com/cYg0HVnaYgjS/?ref=app
3rd Aug 2017, 1:05 AM
Tusiime Innocent Boub
Tusiime Innocent Boub - avatar
+ 12
have you done that part of the course here yet? if(true) { the code in here gets executed } so in the example if(8 == 1) { the code here will be skipped as 8 is not equal to 1 }
3rd Aug 2017, 12:23 AM
jay
jay - avatar
+ 11
that is correct. also worth noting that in c++ 0 is considered a false, any other value is considered true
3rd Aug 2017, 12:27 AM
jay
jay - avatar
+ 2
Never Mind I think I found out by testing it some More. So pretty much In lame-mans terms If you Put: if (5==5) cout<< Correct it will read Correct Because 5 is in fact = to 5 but if you put : IF (5==4) cout<<Correct Nothing will appear due to 5 not being = to 4 therefore making the statement false. Please let me know if im off on something i would really like to fully understand the context of TRUE & False.
3rd Aug 2017, 12:24 AM
Morris House III
Morris House III - avatar
+ 1
if the statement is true it will come in and execute the program if it's false it will not execute as such it checks if it's true or false and executes the cobdition
4th Aug 2017, 2:07 PM
N.sooriya kumar
N.sooriya kumar - avatar
0
// if expression evaluates to be true then statement inside if block is executed. if ( expression) { ... }
13th Aug 2017, 11:58 AM
saurabh makkar
saurabh makkar - avatar