Conditional structures

From Applied Science

One of the first things that you learn is how to make a computer receive a value, process it and return to you something. That's when we need the concept of flow control. You write something that controls the decisions (decisions that you make, not the computer) about what and when to execute something. The simplest flow control structure is IF ... ELSE.

The basic logic is: do this if that is true, else do something else. On one hand you can choose that one case is the one that you want, whereas all others are not. On the other hand, you can choose one exception among all possibilities. The more complicated the execution conditions are, harder it becomes to foresee all cases.

Errors of logic:

  • There is a case left which you did not foresee;
  • The condition includes a case which it should not include;
  • Overlapping conditions which conflict with each other.

It's required to have a good understanding about input/output, variable declaration and arithmetic operations to avoid trouble here

(GOTO - many teachers are against GOTO, therefore you can simply ignore it. One argument against GOTO is that it makes code harder to follow and, generally, it's not very clean. If the teacher is very strict, he/she can subtract points from you program's grade if you did use GOTO)