Why are all of these true?

Write your question here.

A question in my book ask

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.
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#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.
Last edited on
Thanks for the help.
Topic archived. No new replies allowed.