[EMAIL PROTECTED] wrote:



--- In [EMAIL PROTECTED], srikanth poojary
<[EMAIL PROTECTED]> wrote:
> main()
> {
> int i=5;
> printf("%d%d%d%d%d",i++,i--,++i,--i,i);
> }
>

> what is the o/p and why?


Hi,

The o/p will be :

4,5,5,4,5

Finally the value of i will be 5.

This is becoz printf process from right to left.

printf("%d%d%d%d%d",i++,i--,++i,--i,i);

First the rightmost one : i =5

--i => 4

++i => 5

then i-- => first print i that is 5, then decrement,

i++ =>  first print i that is 4, then increment.

Hence, the final value of i=5.

Regards,

Kanaga
Output may be anything and it would be correct. See:
<http://www.eskimo.com/~scs/C-faq/q3.1.html> and the next few questions.








To unsubscribe : [EMAIL PROTECTED]




Yahoo! India Matrimony: Find your life partner online.

To unsubscribe : [EMAIL PROTECTED]




Yahoo! Groups Sponsor
ADVERTISEMENT
click here


Yahoo! Groups Links

Reply via email to