0

Here is code which i am using Please check it first

for(x=0; x<=y; x++){
if(a=x||b=x||c=x){
printf("Value =%d",x);
}
}

In this code x is a base for the loop i want loop till y (variable). Now inside the loop i want to check a condition if x (variable) is equal to any of these Variables a,b,c then print the Value of x.
This code is not working i get Lvalue error with it.
Regards

Edited by DezineGenerator: nothing

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by DezineGenerator
0

The = operator is for assignment in C++. You want the == operator to compare equality:

for (x = 0; x <= y; x++)
{
    if (a == x || b == x || c == x)
    {
        printf("Value = %d", x);
    }
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.