0 0 votes answer the output#include <stdio.h> int main() { int x=0; x++; if(--x){ x=x++; if(x){ printf("hello"); }else{ printf("%d",x); } }else{ x=x+5; if(x){ printf("i win x times"); } else{ printf("you win 5 times"); } } return 0; } Programming in C programming-in-c programming + – shivamSK 845 views answer comment Share Follow Print 0 reply Please log in or register to add a comment.
Best answer 4 4 votes First $X=1$ after post increment and in if condition it will become $X=0$ so its False then it comes in else part $X=5$ So in if Condition it's True coz in C Programming Except $0$ every other number is true either it positive or negative So it will print "i win x times" ꧁༒☬ĿọŗԀ 🆂🅷🅸🆅🅰☬༒꧂ answered Jun 9, 2024 • selected Jun 19, 2024 by shivamSK ꧁༒☬ĿọŗԀ 🆂🅷🅸🆅🅰☬༒꧂ comment Share Follow See 1 comment 1 1 comment reply shivamSK commented Jun 9, 2024 reply Follow flag yes answer is "I WIN X TIMES" correct 0 0 replyShare Please log in or register to add a comment.
1 1 vote After second line in main function x will become 1, but in next line their is pre-increment so x will become 0, and if(0) is false. So if statement will not get executed.Now in the else block their is x =x+5 which makes x=5so the nested if(x) will be true and get executed. Hence I win x times will get printed. ZinxKaltz answered Jun 9, 2024 ZinxKaltz comment Share Follow 0 reply Please log in or register to add a comment.
0 0 votes SolutionIt will print I win x times Bhargobi answered Jan 3, 2025 Bhargobi comment Share Follow 0 reply Please log in or register to add a comment.