Bachelor of Computer Application (BCA) Community Share and Help

Flow Chart and Algorithms

Write an algorithm or draw a flow chart for the following :

To Determin the given number is positive, negative or zero
to find sum of first number
Algorithm to find the sum of first n natural numbers:
1. Read n.
2. Initialize N=1.
3. Initialize sum S=0.
4. Calculate S=S+N.
5. Calculate N=N+1.
6. If N>n, then goto step 7 else goto step 4.
7. Write the sum S.
8. Stop.

Flow Chart Example 1

Draw a flowchart to find the sum of first 50 natural numbers.

Answer: The required flowchart is given in Fig. 1.

Flow Chart Example - Sum of first 50 natural numbers

Fig. 1 Sum of first 50 natural numbers

Flow Chart Example 2

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

Answer: The required flowchart is shown in Fig 2

Flow chart examples - find out the largest of three number

Fig 2 Flowchart for finding out the largest of three number

Flowchart Example 3

Draw a flowchart for computing factorial N (N!)

Where N! = 1?2?3?....N .

The required flowchart has been shown in fig 3

Answer:

Flowchart for computing factorial N

Fig 3 Flowchart for computing factorial N

Advertisement