Here is a question which i am going to explore best to my concepts and knowledge,you can judge for yourself whether i am right or wrong..
int main()
{
int val=10;
printf(":%d",val+1,"-%d",val--);
return(0);
You might not be satisfied with the prove of right to left evaluation so just change the val-- to --val because above example shows the postfix property that is printing before decrementing
int main()
{
int val=10;
printf(":%d",val+1,"-%d",val--);
return(0);
printf(":%d",val+1,"-%d",val--);
If strictly speaking the result of this is undefined as you can read the sequence point post ,
No doubt the evaluation will be from right to left but we can't assure the result...but let us suppose everything goes according to our will or thinking that is smooth evaluation form right or left then first val-- will be evaluated that will decrement the val to 9 then val+1 which lead to print 10 as the output
so the output will be----->:10
To prove the evaluation is from right to left let us print the value of val--;
printf(":%d%s%d",val+1,"-%d",val--);
output--->:10-%d10
You might not be satisfied with the prove of right to left evaluation so just change the val-- to --val because above example shows the postfix property that is printing before decrementing
printf(":%d%s%d",val+1,"-%d",--val);
output--->:10-%d9
Now i thing it will be cleared to you....
May be i am wrong,so please do comment whether you agree with me or not????
if not give the explanation.....
No comments:
Post a Comment
Feel free to comment......