Wednesday, August 12, 2009

Decision Logic

When it comes to Decision Logic, all you have to do is to think of these 3 words IF/THEN/ELSE. Why we need to use Decision Logic? We need to use decision logic because it is the only way computer can choose between one or more set of action. Computer can only choose either one because computer is running on Binaries, so it is either 0 or 1.

Before you start to think of how it works, relax you mind first don't think of complicated stuff first. Computers are not complicated as a human being, computer is just yes and no while a human can answer yes,no and maybe.

How the IF/THEN/ELSE structure function is simple. The computer will either execute Instructions for the True statement or the False statement.

Take the Algorithm below as an example.

IF (x=5) THEN
{ DISPLAY "The value of X is now 5"}
ELSE
{DISPLAY "The value of X is not 5"}
END IF

From the example above, if it fulfills the condition when x=5 then computer will execute the instruction for the true statement. If it does not fulfills it, it will skip through the instruction and proceed to the else part (FALSE part).


No comments:

Post a Comment