You are on page 1of 8

Flowchart Exercises

1. Draw a flowchart and write its program that adds/multiplies two numbers given by the user.
2. Draw a flowchart and write its program that divides two numbers given by user (the first
number is divided by the second number).
3. Draw a flowchart and write its program to convert temperature in Fahrenheit to Celsius.
4. Draw a flowchart and write its program to determine if a given positive integer is even or odd.
5. Draw a flowchart and write its program to read two positive integers, determine which has
greater value and then print this value if it is even.
6. Write a program to find the greatest number within given 3 numbers by the user.
7. Write a program to identify if the water is in ice for, or in liquid form or gaseous for a given
temperatures from the user.
8. Write a program to print numbers divisible by 5, for the integers from 1 to 99.
9. Write a program of the following serial: {1, 4, 9, 16, 25,36, … 121}
10. Write a program of the following serial: 3 + 5 + 7 + 9 + …. + 159 = ?
11. Write a program of program that prints numbers divisible by k, for the integers from m to n.
12. Write a program of the following serial: 2 + 5 + 10 + 17 + 26 + 37+ … + 145 = ?
Q1. Add 10 and 20
To solve this problem we will take a variable sum and set it to zero. Then we
will take the two numbers 10 and 20 as input. Next we will add both the
numbers and save the result in the variable sum i.e., sum = 10 + 20. Finally,
we will print the value stored in the variable sum.

Algorithm (in simple English)


 Initialize sum = 0 (PROCESS)
 Enter the numbers (I/O)
 Add them and store the result in sum (PROCESS)
 Print sum (I/O)

Flowchart
Q2. Find the sum of 5 numbers
In this question we are asked to find the sum of 5 numbers. So, we will take
two variables - sum and count and set both of them to zero. The sum variable
will store the result while the count variable will keep track of how many
numbers we have read.
To solve this problem we will use the concept of loop. In loop or iterative
operation, we execute some steps repeatedly as long as the given condition is
TRUE. In this case we will keep reading the input till we have read 5 numbers.
So, we first initialize sum and count to zero. Then we will take the input and
store it in a variable n. Next we will add the value stored in n to sum and save
the answer in sum.
i.e., sum = sum + n
Then we will increment count by 1 and check if count is less than 5. If this
condition is TRUE then we will take another input. If the condition is FALSE
then we will print the value stored in variable sum.

Algorithm (in simple English)


1. Initialize sum = 0 and count = 0 (PROCESS)
2. Enter n (I/O)
3. Find sum + n and assign it to sum and then increment count by 1
(PROCESS)
4. Is count < 5 (DECISION)
5. if YES go to step 2
else
Print sum (I/O)

Flowchart
Q3. Print Hello World 10 times
This problem is also solved using the loop concept. We take a variable count
and set it to zero. Then we print "Hello World" and increment count by 1.
i.e., count = count + 1
Next we check if count is less than 10. If this is TRUE then we again print
"Hello World" and increment the variable count. On the other hand if the
condition if FALSE then we will stop.

Algorithm (in simple English)


1. Initialize count = 0 (PROCESS)
2. Print Hello World (I/O)
3. Increment count by 1 (PROCESS)
4. Is count < 10 (DECISION)
5. if YES go to step 2
else Stop
Flowchart

Q4. Draw a flowchart to log in to facebook


account
This problem can be solved in many ways so, we will encourage you to think
and draw a flowchart for this problem using your imagination.
To log in to facebook account we first enter the facbook URL
www.facebook.com in our browser like Google, Firefox, Safari, Internet
Explorer etc. This request is sent to the facebook server and it responds by
sending us the home page of facebook.
Next, we enter our registered Email ID and Password and click the Login
button.
Then our login credential is checked. If it is correct, we are show our profile.
On the other hand, if the login credential is wrong then an error occurs and we
are prompted to re-enter our Email ID and Password.
Algorithm (in simple English)
1. Enter www.facebook.com in your browser. (I/O)
2. facebook Home page loads (PROCESS)
3. Enter your Email ID and Password (I/O)
4. Is Email ID and Password Valid (DECISION)
if NO then
Log in error (PROCESS)
go to step 3
else
Display facebook Account (I/O)
Stop

Flowchart
Note!
As there are many ways to solve a given problem so there are many ways to
draw a flowchart.

Q1. Find the sum of the numbers in each set.


You are given hundred numbers divided in ten sets in the following order.
Set 1: 1-10
Set 2: 11-20
Set 3: 21-30

Set 10: 91-100
You have to draw a flowchart that will print the sum of each set.
Solution
To solve this problem we have to apply the concept of loop which was
covered in exercise-1.

Algorithm in simple English


1. Initialize count = 1 and i = 1 (PROCESS)
2. Check if i is less than or equal to 10 (DECISION)
if YES then perform step 3
else STOP
3. Set sum = 0 and j = 1 (PROCESS)
4. Check if j is less than or equal to 10 (DECISION)
if YES then perform step 5
else perform step 9
5. Add count to sum
sum = sum + count (PROCESS)
6. Increment count by 1
count = count + 1 (PROCESS)
7. Increment j by 1
j = j + 1 (PROCESS)
8. Go to Step 4
9. Print sum (I/O)
10. Increment i by 1
i = i + 1 (PROCESS)
11. Go to Step 2

Flowchart