Hi, I have always wondered if it is possible to have an if statement keep running without having to constantly write it. I have tried using loops but that didn't go so well. For example I have the using input numbers into variables many times throughout the program, but every time he is given multiple choices, and each time one of the choices always does the same thing. I don't want to always have to write that statment.
Let's say I have a variable named x. Now, I have the user input a new value to it 100 times in the program, and whenever the variable is 4 I want it to say "you guessed rite!" But, that's a lot of if statements to write! I was asking if there was a way to have 1 if statement check itself constantly.
An expression within a if statement cannot change, only the result.
jmlpor98 wrote:
Now, I have the user input a new value to it 100 times in the program, and whenever the variable is 4 I want it to say "you guessed rite!" But, that's a lot of if statements to write!
You only need one if statement, and that's to check if the user entered the value of 4.