Which of the following is true?
A. 1
B. 66
C. .1
D. -1
E. All of the above
and I picked 1 because 1 is the true value of a boolean. However, the answer in the back of the book is E-All of the above. Can someone explain to me why that is? Thanks a lot.
#include<iostream>
int main() {
if (1) {
std::cout << " 1 is true" << std::endl;
}
if (66) {
std::cout << "66 is true" << std::endl;
}
if (.1) {
std::cout << ".1 is true" << std::endl;
}
if (-1) {
std::cout << "-1 is true" << std::endl;
}
std::cin.ignore();
}
Its not true that -1 is true in any philosophical sense. It was just a pragmatic choice on the part of the creators of the language. 0 is false and !0 is true.