L-value Required Error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gurpreetsambhi
    New Member
    • Apr 2008
    • 1

    L-value Required Error

    /*WHY IT IS GIVING ERROR AS L-Value Required..but when we rewrite as y==1?n=0:(n=1); code will work */
    #include<stdio. h>
    #include<conio. h>

    void main()
    {
    int n,y=1;
    clrscr();
    y==1?n=0:n=1;
    getch();
    }
  • Man4ish
    New Member
    • Mar 2008
    • 151

    #2
    Originally posted by gurpreetsambhi
    /*WHY IT IS GIVING ERROR AS L-Value Required..but when we rewrite as y==1?n=0:(n=1); code will work */
    #include<stdio. h>
    #include<conio. h>

    void main()
    {
    int n,y=1;
    clrscr();
    y==1?n=0:n=1;
    getch();
    }
    In the above example you are assigning value 1 to expression y==1?n=0:n instead of n,so it is giving error when you keep it in bracket y==1?n=0:(n=1); then you are assigning 1 to n as an alternative condition .

    Comment

    Working...