+ 3

#include <iostream> using namespace std; int main() { int x=5 , y=6; if (++x>4 ||++y<8) { cout <<x<<y<<endl;

here output is 66 . Why not 67 while ++x=6 and ++y=7 ?

16th Aug 2018, 11:46 AM
Jakhongir
Jakhongir - avatar
6 Respostas
+ 8
Because in C++ if the first statement of OR is true, other ones won't be checked. ++x>4 -> true, so the whole expression gives us true, no need to check the following ones
16th Aug 2018, 11:55 AM
MarJan
MarJan - avatar
+ 3
MarJan I was confused as well, but you cleared my doubts. Thanks man
16th Aug 2018, 1:22 PM
Dlite
Dlite - avatar
+ 2
thank you !
16th Aug 2018, 4:19 PM
Jakhongir
Jakhongir - avatar
+ 2
for(i=1,i<=20,i++)
12th Jan 2019, 9:10 PM
Teba Teoba Teoba
Teba Teoba Teoba - avatar
0
яхз
10th Sep 2018, 12:20 PM
Иван Слепков
Иван Слепков - avatar
- 1
hsbxbxnskskshdbndnakajdbdjdjsns
18th Aug 2018, 8:51 AM
JASMEET Bhamra