12,545,720 members (61,399 online)
Rate this:
See more:
Hi all.
Please tell me what will be output with explanation.

```#include "stdio.h"

main ( )
{
int x = 2, y = 5;
if (x < y)
return (x = x+y);
else
printf (“z1”);
printf(“z2”);
}
```

Thanks.
Posted 1-Jul-11 20:44pm
Awa_tcp415
Updated 4-Jul-11 6:05am
Joan Murt89.2K
v3

Rate this:

## Solution 1

You've been asked this as a homework question. You can also just compile and run it to find the output and use the debugger to 'explain' it. We don't do homework for people who won't even try.
SAKryukov 2-Jul-11 3:17am

Absolutely, a 5.
--SA
Rate this:

## Solution 3

Try to debug this code. That will help you understand what is really happening.
SAKryukov 2-Jul-11 3:18am

I cannot believe it may happen :<
--SA
Awa_tcp 4-Jul-11 1:02am

It's not just a question ?...

I know the answer but there is something interesting ....

say to whom it is returning
the value..
SAKryukov 5-Jul-11 0:25am

Sorry if you feel my comment was harsh. I did not know that you knew the answer.

The problem is so trivial that I think a person who does no know the answer could have trouble using debugger -- I know that from my experience with others.

If you knew the answer -- sorry for suspecting you did not -- this is the different story. In this case -- why asking it? To share something interesting? But there is nothing interesting in it. It does not teach anything at any level. Redundant "if" (result of the check statically known), no sense -- is that interesting? I don't think so.

Sorry,
--SA
Rate this:

## Solution 2

Output:
function returned with the value of `"7"`
Awa_tcp 2-Jul-11 3:14am

Hi

It is returning "7" to whom .

thanks
Rate this:

## Solution 4

it will return 7 to operating system... under the control of that O.S ( this program would be running))....

Top Experts
Last 24hrsThis month
 CPallini 285 OriginalGriff 240 Karthik Bangalore 110 Mika Wendelius 109 Maciej Los 100
 OriginalGriff 3,627 John Simmons / outlaw programmer 1,627 ppolymorphe 1,441 Suvendu Shekhar Giri 1,378 Karthik Bangalore 1,160