Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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
28th Dec 2016, 1:06 PM
Hatsy Rei
Hatsy Rei - avatar