What is boolean value | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is boolean value

4th Dec 2016, 11:46 PM
Omer Philon
Omer Philon - avatar
7 Answers
+ 5
A boolean variable is a variable that takes two values : - True ( or 1) - False (or 0) If you have : x = 5; x ==4 will return "false" and x==5 will return "true"
4th Dec 2016, 11:55 PM
User3827
+ 1
A boolean is a variable that can only have 2 possible values: true or false
4th Dec 2016, 11:56 PM
Yaaseen Ayub
Yaaseen Ayub - avatar
+ 1
A boolean value is either true or false. Every language represents those in slightly different ways. Most people assume 0 is false and 1 is true. However, many languages consider any non-zero integer to be true. -1 or 387 or -732 might be interpreted as "true". 0 may be interpreted as false, but in some languages, a null string (empty string) or a null object or empty array, all might be interpreted as false. To avoid some of this ambiguity, some languages implement what are referred to as "strict equality operators", which require both operands to be of the same type, differentiating between boolean, int, null string, and null objects. These operators usually have an extra "=" sign to the end. For example ( 1 == true ) might evaluate to true, but ( 1 === true ) would be false, because an int can never be equal to a boolean data type. Likewise for not equal to operators: != vs !== .
5th Dec 2016, 4:22 AM
Leif W
0
Boolean value is a value which can either be true or false.... here 1 is true 0 is false for ex: if(1) cout<<"go to hell mo**#*fu##*r "; in this boolean value is true & hence it will print the output on the screen
5th Dec 2016, 1:40 AM
Rahul Sharma
Rahul Sharma - avatar
0
The bool keyword is an alias of System.Boolean. It is used to declare variables to store the Boolean values, true and false. public class BoolTest { static void Main() { bool b = true; // WriteLine automatically converts the value of b to text. Console.WriteLine(b); int days = DateTime.Now.DayOfYear; // Assign the result of a boolean expression to b. b = (days % 2 == 0); // Branch depending on whether b is true or false. if (b) { Console.WriteLine("days is an even number"); } else { Console.WriteLine("days is an odd number"); } } } /* Output: True days is an <even/odd> number */
5th Dec 2016, 11:49 AM
Akwin Lopez
Akwin Lopez - avatar
0
A boolean (bool for short) is a data type that stores only true or false outcomes. If and else and else-if relies on the bool as if you didnt know already.
6th Dec 2016, 4:13 AM
julio
0
V
4th Oct 2020, 1:32 PM
Abhay Parmar
Abhay Parmar - avatar