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


What bool and char do ?


12/28/2016 12:28:22 PM


1 Answer

New Answer


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