Ask coding questions

← Back to all posts
I want to limit a variable to one of 4 choices
ihabmed240

C language
I want the program to shut down as soon as fasila doesn't equal at least one of those values (0.25,0.75,0.5,0)
Fasila is only the decimal part of number inputed by user.

Answered by MattDESTROYER [earned 5 cycles]
View Answer
Voters
ihabmed240
Comments
hotnewtop
MattDESTROYER

You could an if statement like this:

If you put that in main it should end the program if fasila is equal to 0, 0.25, 0.5 or 0.75; the program should end. (Note: this only runs once, if you need to check this multiple times I would suggest doing something like the below.)

ihabmed240

@MattDESTROYER thank you very much you are my hero for real.

MattDESTROYER

@ihabmed240 No problem :)