What is the output of the following program ? main (){ int x = 2, y = 5; if(x…
2018
What is the output of the following program ?
main (){
int x = 2, y = 5;
if(x < y) return (x = x + y);
else printf ("z1");
printf("z2");
Answer: D. None of these — The condition (x < y) evaluates to true since 2 is less than 5. The code executes the return statement, which terminates the function immediately. Therefore,…
- A.
z2
- B.
z1z2
- C.
Compilation error
- D.
None of these
Attempted by 940 students.
Show answer & explanation
Correct answer: D
The condition (x < y) evaluates to true since 2 is less than 5. The code executes the return statement, which terminates the function immediately. Therefore, the printf statements are unreachable and no output is produced.
Explore the full course: Iocl Engineers Officers Grade A Paper 2
Loading lesson…