What bool and char do ? | Sololearn: Learn to code for FREE!

0

What bool and char do ?

c++

12/28/2016 12:28:22 PM

SwAgBG

1 Answer

New Answer

+8

Let's declare a boolean variable and a char variable and compare the two: bool var1 = true; char var2 = 'x'; Boolean variable 'var1' now stores the value of 'true' or '1'. Basically, we use boolean to evaluate conditional statements. Boolean variables can only store values 'true' or 'false'. cout << var1; // outputs 1 Char variable 'var2' now stores the character 'x'. As described, char variable is used to store single characters to be used in your program later on. cout << var2; // outputs x