Can I use the not operator in C++ on int values?
Strange question, but someone showed me this, I was wondering can you use the not ! operator for int in C++? (its strange to me). #include <iostream> using namespace std; int main() { int a=5, b=4, c=4, d; d = !( a > b && b <= c) || a > c && !b; cout << d; system ("pause"); return 0; } Yes. For integral types, ! returns true if the operand is zero, and false otherwise. So !b here just means b == 0 . This is a particular case where a value is converted to a bool . The !b can be viewed as !((bool)b) so the question is what is the "truthness" of b . In C++, arithmetic types, pointer types and