+ 1
What does this code mean?
#include <iostream> using namespace std; int main() { int x=5; x=!(x>8); cout<<x; return 0; } why output is 1?
6 Answers
+ 3
hi my friend ! attention : x>8 returns false ( that is 0 )
then NOT of false becomes true : !(false)= true
so integer value of (true) is 1 and value of x becomes 1. (x=1)
bye
+ 1
ŰŻÙ
ŰȘ گ۱Ù
ۯۧۯۧێ
+ 1
output is 1 because x>8 is false and ! operater is logical not this to 1 x=not false that is x=true
0
x>8 is a logical operation, but since x is an integer therefore logical results are displayed in form of 0 (means FALSE). Then the !0 becomes 1(means False). therefore output is 1.
0
In x>8 if x=5 then 5>8.it becomes false. But not of false is true. When it is true it returns output 1.
0
Included iostream;
namespace std loaded;
x = !(5>8); !(false) -- true, int cannot be transformed into bool */
1