@umesh...thanks :) this explanation seems to be satisfactory but failed to understand from where @anika and @himanshu were getting 7 6 8....i ran it...output comes out to be 7 6 6 !!
On Sun, Jun 12, 2011 at 6:15 AM, UMESH KUMAR <[email protected]>wrote: > >>>> void call(int a,int b,int c) >>>> { >>>> printf("%d %d %d",a,b,c); >>>> } >>>> >>>> int main() >>>> { >>>> int a=5; >>>> call(a++,a++,++a); >>>> return 0; >>>> >>>> } >>>> >>>> >>>> On Sat, Jun 11, 2011 at 8:21 PM, PRAMENDRA RATHi rathi < >>>> [email protected]> wrote: >>>> >>>>> IN second program: >>>>> in function value are always push in the stack from right. >>>>> so first value is --i that will make i=1 and value 1 will be passed to >>>>> function >>>>> and >>>>> after that i++ that's means i will be passed. >>>>> so 1 will be passed and after passing value. i will changed to 2. >>>>> >>>>> if u want to know why reverse order than can go through: >>>>> http://cs.nyu.edu/courses/fall03/V22.0201-003/c_param.html<http://www.google.com/url?sa=D&q=http://cs.nyu.edu/courses/fall03/V22.0201-003/c_param.html> >>>>> ----------------------------------------- >>>>> PRAMENDRA RATHI >>>>> NIT ALLAHABAD >>>>> >>>>> >>>>> >>>>> When the function is called then formal values PUSH in a >>>>> >>>> > STACK from left to right and POP from left to right finally > so we can obtained the output :7 6 6 ............... > > Since function call ---------------------- > > * call(a++,a++,++a);* > * and *a=5 > > STACK PUSH AS:- > 0::++a --------c > 1::a++ --------b > 2::a++ --------a > > POP AS: > > 0::++a --------c= 6 ( *6)* > * > * > * *1::a++ --------b = 6 (*7*) > > 2::a++ --------a = 7 (*8*) > > So. finally OUTPUT :- > * a=7, b=6, c=6* > * > * > * > * > ************************************** > * > * > > -- > 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.
