0
I am not able to understand boolean
Can any body help me
8 Respuestas
+ 1
no problem;)
+ 3
in js for example if the user pressed the button the condition is true and you do some code for that. else: if he didn't the condition is false and you do other things to handle it.
+ 1
Hi,
A Boolean variable only can take two values: true or false.
It is used to save if the process did make some actions like..
bool isUpdated;
If (getVersion() != getLatestVersion()) {
updateVersion();
isUpdated = true;
}
The standard value of a Boolean variable is false. *IMPORTANT*
In programming values like 0, or something with empty value like "", are taken as nothing, so nothing is the same as false, so if you do that:
int num = 0;
If (num) {
}
else {
}
The compiler will solve the if converting the condition (num) to a Boolean and 0 becomes false, it will execute the else statement.
If you change value of num to any value different to 0 (included negatives) the compiler will take it as a True boolean because it has value.
Hope it helps you
0
thanks a lot
0
A boolean variable can ONLY be true or false.
Good for conditional testing
0
thanks
0
No problem, hope you get a hang of it 🙂 have a nice day 😀
0
Ok thanks