+ 1

Explain code

Int i=5; i=!(i>8); Cout<<i

11th Feb 2019, 8:50 AM
yogesh patel
yogesh patel - avatar
2 Respuestas
+ 1
First line of code is just a variable declaration and initialisation i.e. Int i = 5; The second line has 3 parts 1. it's checking the condition inside the bracket 2. inverse of the result 3. Then settings the new value to i. i =!(i > 8); First it will check the condition inside the brackets i.e. (i > 8) i is 5 and as 5 is not greater then 8 it will return false. so now its i = !(false); As !false is true so i = true which is also represented by 1 so i = 1 And the last line of code is just "i" as standard output
11th Feb 2019, 9:24 AM
Afraz Aslam
Afraz Aslam - avatar
+ 4
i is 5 i > 8 is false ! (i > 8) is true Boolean value 'true' is equivalent to 1, and will be stored as such in an integer variable.
11th Feb 2019, 8:53 AM
Hatsy Rei
Hatsy Rei - avatar