0% found this document useful (0 votes)
3 views

Program Development and Flowcharts 2

Uploaded by

xzmosta123
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Program Development and Flowcharts 2

Uploaded by

xzmosta123
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Programming Languages and Program

Development

1
Flowcharts

• A graphical tool that diagrammatically depicts the steps


and structure of an algorithm or program

2
Flowcharts

• Represent flow of control


– sequences
– selection

3
Sequence

• Series of instructions to be carried out in a fixed


sequential order
• Example 1:
Step A: input number
Step B: add 1 to number
Step C: output number

4
Flowchart: Sequence

• Represented by concatenating instructions


(usually vertically)
Instruction Step A: input number
in rectangular
box
Step B: add 1 to number

Order of execution
indicated by arrows Step C: output number

5
Flowchart: Selection
Arrow labeled Condition
Step A with result of test
if ( condition C1 ) condition test in diamond
{ Step A
<sequence S1>
}
YES NO
else C1 true?
{
<sequence S2>
}
S1 S2
Step C

Step C

6
Example (1)

• Draw a flowchart for a program read two numbers


and find their sum.
Solution:
Step1: Start
Step2: Read the first num1.
Step3: Read the second num2.
Step4: Sum = num1+num2
Step5: Print Sum
Step6: End
7
Example (1) Start

Read the first


Step1: Start
num1
Step2: Read the first num1.
Step3: Read the second num2.
Step4: Sum = num1+num2
Step5: Print Sum
Read the second
Step6: End num2

Sum = num1+num2

Print Sum

End
8
Example (2)

Draw a flowchart for a program find the greater


number between two numbers
Solution:
Step1: Start
Step2: Read/input A and B
Step3: If A greater than B then C=A
Step4: if B greater than A then C=B
Step5: Print C
Step6: End

9
Start
Example (2)
Read A and B
Step1: Start
Step2: Read A and B
Step3: If A greater than B then C=A No Yes
Step4: if B greater than A then C=B Is A > B?
Step5: Print C
Step6: End
No C=A
Is B > A?

Yes

C=B

End Print C

10

You might also like