+ 3
What happens when i insert a random number to a bool variable?
Hello When i create a bool x and then input cin x, what happens when i input a number which is not 0 or 1? Example: bool x; cin >> x; cout <<x; What will be the output for: - 8 - 1 or - 0 ??? https://code.sololearn.com/cr7g6EHxq1ZY/?ref=app
3 Réponses
+ 3
A boolean in C++ will be false only if it is 0. Anything else results in a one.
+ 2
Thank you!!!
+ 1
yes because the compiler can understand only 0 and non zero.zero means true and any non zero number means false