+ 1
What is concept of booleans?
please tell me with one c++ program
8 odpowiedzi
+ 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;
}
+ 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.
+ 3
@hatsyrei - So cookies. Much wow! LOL!!!!!!!
+ 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.
+ 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
+ 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.
+ 1
Dao, in what circumstances would we need to control flow? what do you mean by flow of the program?
0
we can explain boll by (on) (off)