Sei sulla pagina 1di 9

Exercises

1. Which is not true about the arrows used in a flowchart?


i. Direction of arrow shows the flow in a flowchart.
ii. Arrows are used show the sequence of the problem solving.
iii. Arrows are used to connect boxes in a flowchart.
iv. Arrows can be used to represent an input. - False

2 Match the elements of a flowchart and their purpose of use in the


following
Purpose

Use

Calculate total of A, B, C
Indicate that the problem has been
solved.
Find if a number is greater than the
other
Read a number and calculate the
factorial of the number.
Read three numbers
Print the total

Process
Stop

Indicate beginning of a problem


solving flow.

Start

Decision
Loop
Input
Output

3. State True Or False


a) Flowchart assists the programmer while writing the program. - True
b) The direction of flow can be in any direction. False (Should have a
consistent flow direction i.e. either top to bottom, or left to right.
c) Modules are the main programs - True

d) Connectors are used when there are too many flowlines in the flowchart.
False (They are used when you run out of space to draw the rest of the
flowchart)
e) Decision box has only one flowline. - False
4. Complete the crossword puzzle.
1
P

A
R

G
R

Across
1. I am a rectangle in a flowchart. What do I represent?
2. When you want to show a decision making step, you can use this box.
4. You can use me to communicate ideas, graphically represent a problem solving
process.
5. I connect two geometrical boxes in a flowchart.
Down
1. In the flowchart, I represent data or information that is
available
2. All flowcharts begin with me. I am rounded rectangle in
shape.

1. Flow Chart For Odd or Even


Algorithm and flow chart to find whether a number is odd or even.
Algorithm:

ALGORITHM:
1. Start .
2. Read the number from the user.
3. Divide the given number by 2 and get the reminder.
4. If the reminder is equal to zero then the number is even otherwise the number is Odd number.
5. Stop .
Flow chart:

2. Flow Chart For Largest of 3 Numbers


2. Draw a flowchart to find the largest of three numbers A, B, and C.

Step
Step
Step
Step

1:
2:
3:
4:

Start
Declare variables a,b and c.
Read variables a,b and c.
Check If a>b and If a>c
Display a is the largest number.
Else
Display c is the largest number.
Else check
If b>c
Display b is the largest number.
Else
Display c is the greatest number.

Step 5: Stop

3. Flow Chart For Product of first n natural numbers


Algorithm:

1. Read n.
2. Initialize product=1.
3. If i< n Calculate product = product*i
4. If i>n,
5. Write the Product .
5. Stop.
2.

Flow Chart:

6. Flow Chart For Factorial


Algorithm and flowchart to find the factorial of a given number
Factorial of 5 = 1*2*3*4*5=120
Algorithm:

Step 1: Start
Step 2: Declare variables n,factorial and i.

Step 3: Initialize variables


factorial 1
i 1
Step 4: Read value of n
Step 5: Repeat the steps until i=n
5.1: factorial
f a ct or i a l * i
5.2: i
i + 1
Step 6: Display factorial
Step 7: Stop
Flow Chart:

7. Write an algorithm to check whether a number entered by user


is prime or not.

Step 1: Start
Step 2: Declare variables n,i,X.
Step 3: Initialize variables
X1
i
2
Step 4: Read n from user.
Step 5: Repeat the steps until i<(n/2)
5.1 If remainder of ni equals 0
X0

Go to step 6
5.2 i
i +1
Step 6: If x=0
Display n is not prime
else
Display n is prime
Step 7: Stop

8. Write an algorithm to find the Fibonacci series till term1000.

Step
Step
Step
Step
Step

1: Start
2: Declare variables first_term,second_term and temp.
3: Initialize variables first_term
0 s econd _ t e r m1
4: Display first_term and second_term
5: Repeat the steps until second_term1000
5.1: temp
s e cond _ t er m
5.2: second_term
s ec on d _ t er m+f i r s t t er m
5.3: first_term
t emp
5.4: Display second_term
Step 6: Stop

b) Draw a flow chart to find the Fibonacci series without temp variable.

Potrebbero piacerti anche