What is concept of booleans? | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
+ 1

What is concept of booleans?

please tell me with one c++ program

13th Jan 2017, 2:52 AM
Rushikesh Kumbhar
8 Antworten
+ 11
Boolean variables are variables which can store conditional values, i.e. true, false (1, 0). #include <iostream> using namespace std; int main() { bool ident = false; int cookies; cout << "Please input number of cookies." << endl; cin >> cookies; if (cookies > 10) { ident = true; } if (ident) { cout << "So cookies. Much wow." << endl; } else { cout << "Not wow." << endl; } return 0; }
13th Jan 2017, 3:08 AM
Hatsy Rei
Hatsy Rei - avatar
+ 3
Boolean (often shortened to bool) are a data type that can only hold 2 states, namely true, and false. They can be used directly into conditional statements, and are generally extremely useful for controlling the flow of the program.
13th Jan 2017, 3:04 AM
Dao
Dao - avatar
+ 3
@hatsyrei - So cookies. Much wow! LOL!!!!!!!
13th Jan 2017, 4:22 AM
Derek Raimann
Derek Raimann - avatar
+ 3
@Mich You'll often find yourself wanting to make your program behave differently depending on conditions, and Boolean values (stored in variables, literals, or returned by functions/properties) are fundamental in making your program automatically decide how to behave.
8th Feb 2017, 7:04 PM
Dao
Dao - avatar
+ 2
//two boolean variables: one true, one false bool trueVar = true; //first variable bool falseVar = false; //second variable //evaluate if ifrst variable is true if (trueVar==true){ cout<<"the fisrt variable is true"; } //evaluate if second variable is true if (falseVar==true){ cout<<"the second variable is true"; }else{ //if second variable is not true cout<<"the second variable is false"; } Output will be the first variable is true the second variable is false
13th Jan 2017, 3:07 AM
seamiki
seamiki - avatar
+ 2
boolean is a data type of size 1 byte in c++. boolean only contain two values true (1) and false (0).This type of data type is used when we want to deal with true and false.
2nd Feb 2017, 5:41 AM
Ashu Bagul
Ashu Bagul - avatar
+ 1
Dao, in what circumstances would we need to control flow? what do you mean by flow of the program?
8th Feb 2017, 12:35 PM
Mich
Mich - avatar
0
we can explain boll by (on) (off)
5th Feb 2017, 2:42 PM
Ali
Ali - avatar