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;
}
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.
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..
as you mention at above explanation of if's valid condition example 4th one is false but not true..
Franco said:
1 decade ago
L value always must be a variable and should not be a constant.
R value always must be a constant to assign for that variable.
R value always must be a constant to assign for that variable.
(1)
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;
}
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;
}
Anonymous said:
10 years ago
@Navi.
It should be:
#include<stdio.h>
int main()
{
int i = 10, j = 15, a, b;
if((a=i % 2) == (b= j % 3))
printf("IndiaBIX\n");
return 0;
}
It should be:
#include<stdio.h>
int main()
{
int i = 10, j = 15, a, b;
if((a=i % 2) == (b= j % 3))
printf("IndiaBIX\n");
return 0;
}
Anjali said:
9 years ago
Nice explanation, thanks @Sundar.
Prashant3393 said:
8 years ago
Thanks @Sundar.
Ravi mishra said:
8 years ago
Please tell me the meaning of Lvalue.
Nikhil said:
8 years ago
Thanks @Sundar.
(1)
Natasha said:
7 years ago
Thanks @Sundar.
Dhinesh said:
7 years ago
Thanks @Sundar.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers