A lot of the time when we write a program we tell a computer what to do in a very straight forward manner. We might tell it to print the value of a pre-defined variable, or take some input from a user and make a calculation based on it. That is all well and good, but what about those cases where the program is not so straight forward? What if I grab some input from a user and the user did not enter in the proper data? Or what if I want to give the user some choices? In those instances, we need to use if statements. Simply put, an if statement allows you to say: if this happens, do this. ...
↧