I cant understand the third one

On Mon, Aug 1, 2011 at 6:09 PM, Nikhil Gupta <[email protected]>wrote:

> printf scans the arguments from right to left for any arithmetic operations
> to be performed. If found, they are evaluated according to their precedence.
>
> In 1. main()
>
>> {
>>
>>  int i=1;
>>
>> printf("%d\t%d\t%d\t",i,i++,i);
>>
>> }
>>
>> output: 2 1 2
>>
>> Scanned from right. i++ is encountered. It is evaluated, but keep in mind
>> that this is post increment. So this i will still be displayed without the
>> effect of the increment operator.
>>
> Other i's are incremented though.
>
>>  2.main()
>>
>> {
>>
>>  int i=1;
>>
>> printf("%d\t%d\t%d\t",i,++i,i);
>>
>> }
>>
>> output: 2 2 2
>>
>> Again, the same logic applies here as well. Here we have pre-increment. So
>> this i will have the incremented value.
>>
>>
>>  3.main()
>>
>> {
>>
>>  int i=1;
>>
>> printf("%d\t%d\t%d\t",i,i++,i++);
>>
>> }
>>
>> output: 3 2 1
>>
>> I'm sure you can figure this one and the next one out.
>>
>>
>>  4.main()
>>
>> {
>>
>>  int i=1;
>>
>> printf("%d\t%d\t%d\t",i,++i,++i);
>>
>> }
>>
>> output: 3 3 3
>>
>>
>>
>>
>>
>>
>>
>>
>> Regards
>> by THANU
>>
>>  --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/algogeeks?hl=en.
>>
>
>
>
> --
> Nikhil Gupta
> Senior Co-ordinator, Publicity
> CSI, NSIT Students' Branch
> NSIT, New Delhi, India
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to