C project exercise in operators

in the grocessory store part 2 i declared a variable like this and its showing an error int dayOfWeek >= 0; error is "expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘attribute’ before ‘>=’ token int dayOfWeek >= 0; whats wrong here?

1 Like

You can’t assign a value to a variable using a comparison operator (such as >= or ==). You need to use the assignment operator (=):

int someVar = 8;
//that is "legal" code
int someOtherVar == 8;
//that isn't "legal" code
1 Like

ya thankyou,i thought we can declare variable with >5 such types so,we cannot.we can only define these conditions in if statements or loops etc not at variable declararion right?

Yes, that’s correct.

1 Like