C Programming - Control Instructions - Discussion

Discussion Forum : Control Instructions - Point Out Correct Statements (Q.No. 2)
2.
Which of the following statements are correct about the below program?
#include<stdio.h>
int main()
{
    int i = 10, j = 15;
    if(i % 2 = j % 3)
        printf("IndiaBIX\n");
    return 0;
}
Error: Expression syntax
Error: Lvalue required
Error: Rvalue required
The Code runs successfully
Answer: Option
Explanation:

if(i % 2 = j % 3) This statement generates "LValue required error". There is no variable on the left side of the expression to assign (j % 3).

Discussion:
20 comments Page 2 of 2.

Navi said:   1 decade ago
/* Note: GCC Compiler (32 Bit Linux Platform). */

Then this is also not working why?

#include<stdio.h>
int main()
{
int i = 10, j = 15, a, b;
if((a=i % 2) = (b= j % 3))
printf("IndiaBIX\n");
return 0;
}

Sameer said:   1 decade ago
@sundar,
as you mention at above explanation of if's valid condition example 4th one is false but not true..

Vinita Jain said:   1 decade ago
I want to know what is Rvalue. Please explain.

Priyanka.s said:   1 decade ago
Can any one explain what is meant by Rvalue?

Priyanka.s said:   1 decade ago
@sundar good explanation thank you.

Siva said:   1 decade ago
I can't understand I want clear explanation. Why we use L value.

Praveen said:   1 decade ago
@Sundar.. Good explanation :)

Keerthi kumar said:   1 decade ago
@sundar ...thanks..

Rajat Rahul said:   1 decade ago
@Ravinder: In 5 and 6 there are no any identifier immediet to the left which should be mendatory to have the result of that expression.

Ravindar said:   1 decade ago
I can't understand your explanation. Please clearly explanation. Lvalue means?


Post your comments here:

Your comments will be displayed after verification.