the arguments are passed from right to left in a function... initially ptr is pointing to location of 98 (i =1)
the last argument ++ptr makes it point to 99 therefore output of *e = 99 the second last argument passes pointer to 99 only and then increments its location to i=3 i.e 100...therefore output of *d = 99 and *c = 100 the second argument is pointing to location of i=3 only and then decrements to point to location of i=2..therefore output of *a =100 and *b =100.. hope you understood the sequence of outputs...:) :) On 6/22/11, Piyush Sinha <ecstasy.piy...@gmail.com> wrote: > r u sure the last output is also 100..for me its coming 99 > > On 6/22/11, udit sharma <sharmaudit...@gmail.com> wrote: >> #include<stdio.h> >> int main() >> { >> void print(int *,int *,int *,int *,int *); >> static int arr[]={97,98,99,100,101,102,103,104}; >> int *ptr=arr+1; >> print(++ptr,ptr--,ptr,ptr++,++ptr); >> return 0; >> } >> void print(int *a,int *b,int *c,int *d,int *e) >> { >> printf("%d\t%d\t%d\t%d\t%d\n",*a,*b,*c,*d,*e); >> } >> >> Why the output is: >> 100 100 100 99 100 >> >> >> -- >> Regards >> UDIT >> DU- MCA >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to algogeeks@googlegroups.com. >> To unsubscribe from this group, send email to >> algogeeks+unsubscr...@googlegroups.com. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> >> > > > -- > *Piyush Sinha* > *IIIT, Allahabad* > *+91-8792136657* > *+91-7483122727* > *https://www.facebook.com/profile.php?id=100000655377926 * > -- *Piyush Sinha* *IIIT, Allahabad* *+91-8792136657* *+91-7483122727* *https://www.facebook.com/profile.php?id=100000655377926 * -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.