0% found this document useful (0 votes)
3 views30 pages

Algorithm&Flowchart I

The document provides an overview of algorithms and flowcharts, explaining that algorithms are step-by-step procedures for solving computational problems, while flowcharts visually represent these algorithms. It includes various examples of algorithms and flowcharts for tasks like calculating sums, checking eligibility, and determining grades. Additionally, it covers basic data types and includes several flowchart exercises for practice.

Uploaded by

lira160172
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
3 views30 pages

Algorithm&Flowchart I

The document provides an overview of algorithms and flowcharts, explaining that algorithms are step-by-step procedures for solving computational problems, while flowcharts visually represent these algorithms. It includes various examples of algorithms and flowcharts for tasks like calculating sums, checking eligibility, and determining grades. Additionally, it covers basic data types and includes several flowchart exercises for practice.

Uploaded by

lira160172
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 30

Algorithm & Flowchart

1
Algorithm

▪ Before writing program, we need to write the steps to solve the problem
in simple English language

▪ This step by step procedure to solve a well-defined computational


problem is called Algorithm

▪ In short, algorithms are used to simplify the program implementation.

2
Flowchart

▪ It is a diagrammatic representation of an algorithm

▪ A flowchart is a type of diagram that represents a workflow or process

▪ A step-by step approach to solve a task by using some symbols

3
Flowchart Symbols:

Pre Defined Process


Start / Stop

Input / Output Decision

Process Data Flow Lines

Connector

4
5
Write an algorithm to read two numbers and find their sum.

6
Find the area of a Circle of radius r.

7
Write an algorithm (FlowChart) to find the area of a rectangle.

8
Write an algorithm in flowchart that finds the average of three numbers

9
IF

Create a flowchart for a simple login system. The flowchart should include steps for entering a
username and password, checking their validity, and displaying a success or failure message.

No

Yes

Stop
10
IF

Write an algorithm to check whether he is eligible to drive, (more than or equal to 18


years old)

No
No

Yes

11
Create a flowchart to convert the weight in kg to lbs. ( 1kg =2.2 lbs)

Create a flowchart to convert the distance in km to miles. ( 1km = 0.6 mile)

Create a flowchart to check if a given number is positive, negative, or zero.

Design a flowchart to determine if a year is a leap year.

Design a flowchart to determine the grade of a student based on the percentage obtained.

Create a flowchart to simulate a simple ATM withdrawal process.

12
To decide the mark is pass or Fail
START

INPUT mark

NO Mark Yes
>40

OUTPUT OUTPUT
“Fail” “Pass”

13
STOP
To decide the day is weekday or weekend
START

INPUT Day

Day==
NO Saturday Yes
OR
Sunday

OUTPUT OUTPUT
“Weekday” “Weekend”

14
To decide a bigger number of two numbers

START

INPUT x,y

NO Yes
x>y

OUTPUT “y OUTPUT “x
is bigger” is bigger”

STOP 15
To decide the mark is A*, A, B, C or D. (mark > 90 =A*,
mark>80 =A, mark>60 =B, mark >40 =C, otherwise D.
INPUT mark

NO NO NO NO
Mark> Mark> Mark> Mark>
=90 80 60 40

Yes Yes Yes Yes

OUTPUT
“A*” OUTPUT “A” OUTPUT “B” OUTPUT “C” OUTPUT “D”

16
STOP
For Loop and While Loop

A for loop repeats statements as long as the last A while loop is to execute statements as
item in the range has not been reached yet. long as a condition holds.
17
Conditional
Draw a flowchart to reads two values, determines the largest value and prints the
largest value with an identifying message.

18
Basic Data Types
Integer : Whole Number

Double : Decimal Number

Char : One character

String : Text

Boolean : True or False

19
Draw the flow chart to find the difference of two numbers and show the result.

Draw flowchart to calculate cashback. Ask user to enter purchase amount. If purchase amount is >100, then
Give cashback to 100 else make no change to cashback . Display the cashback.

Flowchart to print the Even numbers between 9 and 100.

Calculate the flowchart to decide whether it is loss or profit.

Create a flowchart that displays your age five years from now.
The algorithm should have a variable that is initialized to your current age.

20
Flowchart to print numbers from 1 to 10 using loop

START

N=1

N<11
N=N+1

OUTPUT N

STOP

21
Flowchart to print odd number between 1 to 10

START

N=1

N<10
N=N+2

OUTPUT N

STOP

22
Flowchart to print even numbers from 1 to 10

START

N=2

No
N<=10 N=N+2

YES

OUTPUT N

STOP 23
Flowchart to print even numbers from 1 to 50

START

X=1

Yes
X>50

No
Yes
X%2=0 OUTPUT X

No

X=X+1

STOP 24
Flowchart to find and output Profit or Loss Amount
START

INPUT Cost

INPUT
SellingPrice

YES
SellingPrice > Cost Profit=SellingPrice-Cost

No OUTPUT
Profit
Loss=Cost-SellingPrice

OUTPUT
Loss

STOP
Flowchart to print sum up of all numbers from 1 to 5

26
Flowchart to print sum up of all numbers from 1 to 5

27
Flowchart for the problem of printing even numbers between 9 and 100:

28
29
1.Write an algorithm to check whether given number is positive , negative or
zero.

2.Create a flowchart that ask the user's age. Compute and display his/her
age five years from now.

3.Draw a flowchart that will ask the user to enter a character indicating the
user's gender. If the user enters 'M' display "You're a male". If not assume
that the user is a female. Thus, display "You're a female".

4.Create a flowchart that asks the user to enter a number from


1-3. If 1 is entered, print "Hello"; if 2 is entered, print "Hi", and if 3 is entered
, then print "Bye".

5. Display list of numbers from 100-0 and decrement by 10. 30

You might also like