5 votes 5 votes What is the output of tho following program? main(){ int x=2, y=5; if(x<y) return (x=x+y); else printf("z1"); printf("z2"); } $z2$ $z1z2$ Compilation error None of these Programming in C isro2018 programming output + – Arjun asked Apr 22, 2018 edited Jan 24 by makhdoom ghaya Arjun 9.8k views answer comment Share Follow See all 4 Comments See all 4 4 Comments reply Akshay Koli 4 commented Apr 22, 2018 reply Follow Share option D is correct. 0 votes 0 votes Akshay Koli 4 commented Apr 22, 2018 reply Follow Share yes the answer is correct. option D. 2 votes 2 votes Setika Mehra commented Sep 23, 2020 reply Follow Share why “ printf("z2");” is not executed? 1 votes 1 votes nikhilsaxena835 commented Dec 25, 2023 reply Follow Share Returning int without specifying return type is a compiler error since c99. https://stackoverflow.com/questions/30542092/function-without-return-type-specified-in-c 0 votes 0 votes Please log in or register to add a comment.
Best answer 8 votes 8 votes This code will first replace value of variable x by (5+2)=7 because x<y.Then x will return it's current value 7.So no output will be printed.i.e option D is correct. Sambit Kumar answered Apr 22, 2018 selected Apr 23, 2018 by ManojK Sambit Kumar comment Share Follow See all 3 Comments See all 3 3 Comments reply Lelouch Lamperoug commented Apr 24, 2018 reply Follow Share https://ideone.com/9XlV6U It throws runtime error 0 votes 0 votes VS commented Apr 30, 2018 reply Follow Share https://onlinegdb.com/rkzf6QNpf Not always 1 votes 1 votes Sambit Kumar commented Apr 30, 2018 reply Follow Share Use standard c compiler 0 votes 0 votes Please log in or register to add a comment.
1 votes 1 votes answer is (D) jjayantamahata answered Apr 22, 2018 edited Apr 22, 2018 by jjayantamahata jjayantamahata comment Share Follow See all 0 reply Please log in or register to add a comment.
1 votes 1 votes option D is correct sachin! answered Apr 22, 2018 sachin! comment Share Follow See all 0 reply Please log in or register to add a comment.
1 votes 1 votes None of these. (D) Runtime Error Rustam Ali answered Apr 23, 2018 Rustam Ali comment Share Follow See all 2 Comments See all 2 2 Comments reply Siddharth Bhardawaj commented Apr 24, 2018 reply Follow Share can anyone explain why it is not showing any output? 0 votes 0 votes bittu9934 commented Nov 7, 2023 reply Follow Share because of return statement. it terminates the code. in the code was like #include<stdio.h> int main (){ int x=2, y=5; if (x<y) return printf(“%d”,x+y); else printf(“z1”); printf(“z2”); } in the above case the output will be 7 because once the “return” function is executed, the whole code will be terminated. 0 votes 0 votes Please log in or register to add a comment.