|| and && operators are called short circuit operators and need not necessarily evaluate the entire expression. In ex 1, m= ++i && ++j || ++k; here, ++i and ++j are done. then the result is orred with ++k; here, irrespective of the value of the right side(++k), the result would always be 1. Hence, the results.
On Mon, Jun 13, 2011 at 6:12 PM, sahil <[email protected]> wrote: > can sme body tell me......? > > 1) > #include <stdio.h> > int main() > { > int i= -3, j=2 ,k=0, m; > m= ++i && ++j || ++k; > printf("%d %d %d %d\n",i,j,k,m); > return 0; > > } > output: > -2 3 0 1 > > 2)#include <stdio.h> > int main() > { > int i= -3, j=2 ,k=0, m; > m= ++i || ++j && ++k; > printf("%d %d %d %d\n",i,j,k,m); > return 0; > > } > > output: > -2 2 0 1 > > > 3) > #include <stdio.h> > int main() > { > int i= -3, j=2 ,k=0, m; > m= ++i && ++j && ++k; > printf("%d %d %d %d\n",i,j,k,m); > return 0; > > } > > output: > -2 3 1 1 > > > > how came this output.........??????????? > in the first code why..k is not incremented.....?? > and hw the value of m came out to be 1...? > > > -- > 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. > > -- Regards, Shachindra A C -- 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.
