0

I am not able to understand boolean

Can any body help me

22nd Jul 2018, 10:37 AM
Satyam Sks
8 Answers
+ 1
no problem;)
22nd Jul 2018, 10:54 AM
Dror Dahari
Dror Dahari - avatar
+ 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.
22nd Jul 2018, 10:53 AM
Dror Dahari
Dror Dahari - avatar
+ 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
22nd Jul 2018, 11:52 AM
Guillem Padilla
Guillem Padilla - avatar
0
thanks a lot
22nd Jul 2018, 10:54 AM
Satyam Sks
0
A boolean variable can ONLY be true or false. Good for conditional testing
22nd Jul 2018, 10:54 AM
Olof
Olof - avatar
0
thanks
22nd Jul 2018, 10:55 AM
Satyam Sks
0
No problem, hope you get a hang of it 🙂 have a nice day 😀
22nd Jul 2018, 11:04 AM
Olof
Olof - avatar
0
Ok thanks
22nd Jul 2018, 11:04 AM
Satyam Sks