Algorithm

25 Mar 2012

Decisions (Switching logic)

okk guys now i want to share about Decisions (Switching Logic),,,,,


Switching logic consists of two components - a condition and a goto command depending on the result of the condition test. The computer can determine the truth value of a statement involving one of six mathematical relations symbolized in the table below:

Symbol                          Meaning
==                                   Equals
!=                                  Not Equal
<                                        Less
<=                            Less than or equal to
>                                    Greater than
>=                          Greater than or equal to

In practice, the computer is presented not with a true/false statement, but with a question having a "Yes" or "No" answer, for example if A = 10, B = 20, K = 5, and SALES = 10000, then:

Condition (Question)             "Answer"
Is A == B?                              No
Is B > A?                                Yes
Is K <= 25?                            Yes
Is SALES >= $5000.00?        Yes

With each question, the computer can be programmed to take a different course of action depending on the answer. A step in an algorithm that leads to more than one possible continuation is called a decision. In flowcharting, the diamond-shaped symbol is used to indicate a decision. The question is placed inside the symbol, and each alternative answer to the question is used to label the exit arrow which leads to the appropriate next step of the algorithm. The decision symbol is the only symbol that may have more than one exit. The example below shows the flowchart for a program that reads two numbers and displays the
numbers read in decreasing order:


The equivalent Pseudocode is shown below. Note that with Pseudocode, indentation is used to show the various steps that apply to a decision:

Read A, B
If  A  is less than B
       BIG = B
       SMALL = A
else
       BIG = A
       SMALL = B
Write (Display) BIG, SMALL

naahh guys,,, that all about decision (switching logic),, for the mistake i'm sorry about that.....


hope you can learn and understand the matery.....

always try and keep fighting guys..!!!

Don't Give Up.....!!!!??.^~^

Tidak ada komentar:

Posting Komentar