+ 2

Please give me explanation

#include <stdio.h> int main() { int x=0,y=1; printf("%d",++x | | ++y); printf("%d %d",x,y); return 0; }

25th Nov 2021, 11:49 AM
J SAI JAI BHARGAV
J SAI JAI BHARGAV - avatar
2 Antworten
+ 5
No need for explaining. There is no header with name studio.h ----- If you mean <stdio.h> there then the output is fairly simple. 1) "x" is initialised with 0 and "y" with one 2) logical OR (||) is left associative, that means expression (++x) would be evaluated first, which increments the value of "x" to 1 and evaluates to be "true" so overall expression simply returns 1 ( without even evaluating (++y) as it would not affect the results ) 3) now as the final value of both *x* and *y* is 1, which is then added to output buffer. Resulting in output ( newline and comments added for clarity resons only ) 1 // from first print stmt 1 1 // from second print stmt
25th Nov 2021, 12:06 PM
Arsenic
Arsenic - avatar
0
Martin Taylor The output is 1 1 1
25th Nov 2021, 12:06 PM
J SAI JAI BHARGAV
J SAI JAI BHARGAV - avatar