@Ashish in the first one ++ is a post increment so its associativity
is from L->R... also acc to
 http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B
precedence of (post inc operator) is greater than *(derefrence) so acc
to me s++ should take place first.... y output is A first it should be
'B'

On Aug 23, 7:38 am, Sanjay Rajpal <srn...@gmail.com> wrote:
> +1 to ADITI.
>
> Sanju
> :)
>
> On Mon, Aug 22, 2011 at 2:51 PM, Ashish Sachdeva <ashish.asachd...@gmail.com
>
>
>
>
>
>
>
> > wrote:
> > for the 1st printf i hv this explanation:
> > precedence of ++ is greater then *   ... but associativity of both of
> > them is right to left...
> > thats why dereferenced takes place 1st and then the pointer is
> > incremented...
>
> > rest is fine...
>
> > correct me if i m wrong...
>
> > On Aug 22, 3:47 pm, aditi garg <aditi.garg.6...@gmail.com> wrote:
> > > in frst printf we acess *s and s is incremented later...so it prints A bt
> > at
> > > the same time s points to B now...
> > > In 2nd printf s is incremented frst and thn dereferencd...after
> > incrementing
> > > it points to C and whn we dereference it we get C
> > > in the third printf *s=C whn we increment this we get D
> > > so the ans wud be ACD...
> > > I hope its  clear
>
> >  > On Mon, Aug 22, 2011 at 4:03 PM, MANNU <manishkr2...@gmail.com> wrote:
> > > > main()
> > > > {
> > > > char ch[]="ABCD";
> > > > char *s;
> > > > s=ch;
> > > > printf("%c",*s++);
> > > > printf("%c",*++s);
> > > > printf("%c",++*s);
> > > > }
>
> > > > Can anyone plz tell me the concept behind output??
>
> > > > --
> > > > 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.
>
> > > --
> > > Aditi Garg
> > > Undergraduate Student
> > > Electronics & Communication Divison
> > > NETAJI SUBHAS INSTITUTE OF TECHNOLOGY
> > > Sector 3, Dwarka
> > > New Delhi
>
> > --
> > 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.

-- 
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.

Reply via email to