+ 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?
6 Réponses
+ 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
+ 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 }
+ 11
that is correct. also worth noting that in c++ 0 is considered a false, any other value is considered true
+ 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.
+ 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
0
// if expression evaluates to be true then statement inside if block is executed.
if ( expression) { ... }