@vaibhav.....i don't think there is any rule like you mentioned.....if it is plz mention it's source
i think the explanation by aditya is correct it's just due to the precedence order which is >= ?: = in descending order hence first >= is evaluated then ?: followed by =...due to which lvalue error occurs as constant is on the left side !! On Mon, Jul 11, 2011 at 2:08 PM, vaibhav shukla <[email protected]>wrote: > remember in C , the false statement cannot be used for assignment, if u > write it without braces.It is allowed in C++ but not in C > In C compiler would treat it as what aditya has explained.hence the error. > > On Mon, Jul 11, 2011 at 12:59 PM, aditya pratap < > [email protected]> wrote: > >> this is something like this thats why it is giving lvalue required. >> u r going to store the the value over value which is not a variable at >> left hand side. >> >> main(){int a=10,b; >> (a>=5?b=10:b)=20;printf >> <http://www.opengroup.org/onlinepubs/009695399/functions/printf.html>("%d\n",b);} >> >> >> >> >> On Mon, Jul 11, 2011 at 12:47 PM, geek forgeek <[email protected]>wrote: >> >>> #include<stdio.h> >>> main(){int a=10,b; >>> a>=5?b=10:b=20;printf >>> <http://www.opengroup.org/onlinepubs/009695399/functions/printf.html>("%d\n",b);} >>> >>> y this is asking for lvalue >>> while this(below) not? >>> >>> >>> #include<stdio.h> >>> main(){int a=10,b; >>> a>=5?b=10:(b=20);printf >>> <http://www.opengroup.org/onlinepubs/009695399/functions/printf.html>("%d\n",b);} >>> >>> >>> -- >>> 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 >> Aditya Pratap >> MCA II >> >> -- >> 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. >> > > > > -- > best wishes!! > Vaibhav Shukla > 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 [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.
