You are on page 1of 5

Flow Charts

A flowchart is a diagrammatic representation of the processes involved in arriving at a solution to a problem. While many symbols are included in its notation, the most important are:

Process or operation

Decision

Termination

Flow of Logic

Input/ Output

Flow Chart 1 Sequence Input two numbers and display the average. START

Input A, B Avg = (A +B)/2

Print Avg

STOP

Flow Chart 2 Selection Input two numbers and displays the higher value. START

Input A, B No A>B? Yes High = A High = B

Print High

STOP

Briefly describe the following structured control constructs. Sequence The work which has to done in order is called Sequence. Its very important to write instructions are in the write order in which there written.

Selection There are many oceanic where a program is requires to include a range at alternative actions a choice between two actions based on a conditions is called Selection.

Iteration The sequence at instructions which is repeated is called A Loop or repeating set of statements more than once until a given condition is satisfied is called Repetition.

Flow Chart 3 Selection Input three numbers and displays the highest value.

START

Input A, B, C

NO

A>B?

Yes

Yes

B>C? No No

A>C?

Yes

Print B

Print C

Print C

Print A

STOP

Briefly describe the following three types of repetitions While loop Sequence of instructions that is repeated until a given condition satisfied or true. Such as agreement with data element or completion of a count is satisfied. Repeat/ Until Loop An action or block of actions until a true conditions occur. This type of loop is often use for processing input data. Which will have a codes item at the end of the data? Indicate that the end of the data has been reached. For Loop The third type of loop which we shall use when no of repetitions is known in advance is a for loop. This in its symbols from user two values of a variables. The starting and final condition for the action. The variable is incremented on each interaction until it. Reaches the value identify as the final state.

Flow Chart 4 Repetition Find the sum of first five Natural numbers. START

Sum = 0

N=1

N <=5 ? Yes Sum = Sum + N

No

N=N+1

Print Sum

STOP

Dry run the above flow chart Step 1 2 3 4 5 6 N <=5 ? True True True True True False N 1 2 3 4 5 6 Sum 1 3 6 10 15 15

Flow Chart 6 Repetition - Find factorial of a positive integer number input through the keyboard. START

Input Num

X = 1, Fac * X

Fac = Fac * X

X=X+1

No X > Num ? Yes Print Fac

STOP

Dry run the above flow chart assuming that Num is 5 Step Num X Fac X > Num ?

You might also like