[go: up one dir, main page]

0% found this document useful (0 votes)
15 views18 pages

Chapter 5 Flow Chart and Pseudo Code

The document provides a comprehensive guide on flow charts and algorithms, including basic diagrams, condition representations, and various algorithms for mathematical operations. It covers flow charts for finding sums, maximum values, and calculating areas, as well as algorithms for tasks like printing even numbers and calculating simple interest. Additionally, it includes Python programs for determining number ranges and calculating student grades based on marks.

Uploaded by

bhura.aarna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views18 pages

Chapter 5 Flow Chart and Pseudo Code

The document provides a comprehensive guide on flow charts and algorithms, including basic diagrams, condition representations, and various algorithms for mathematical operations. It covers flow charts for finding sums, maximum values, and calculating areas, as well as algorithms for tasks like printing even numbers and calculating simple interest. Additionally, it includes Python programs for determining number ranges and calculating student grades based on marks.

Uploaded by

bhura.aarna
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 18

Flow Chart and Pseudo code Swati Jain

Contents
1. Flow Chart Basic Diagrams...................................................................................................................2
2. If condition representation in flow chart.............................................................................................3
3. Flow Chart showing condition statement............................................................................................4
4. Flow Chart and algo to find sum of 2 numbers....................................................................................5
5. Flow Chart and algo to find the greater number among 2 numbers....................................................6
6. Flow Chart and algo to calculate sum of first n natural numbers.........................................................7
7. Flow Chart and algo to calculate area and perimeter of a rectangle.................................................10
8. Algorithms.........................................................................................................................................11
1. Calculate Base ^Power...................................................................................................................11
2. To print even numbers from 1 to N................................................................................................12
3. To find max of three numbers........................................................................................................12
4. Check whether the number if positive or negative........................................................................12
5. Check whether odd or even...........................................................................................................13
6. Print square of a number...............................................................................................................13
7. Calculate Simple Interest...............................................................................................................14
8. Find the product of first n natural numbers...................................................................................15
9. Python Programs...............................................................................................................................16
9. Program to find whether a number is in the range........................................................................16
10. WPT print the square if the number entered is even, otherwise print its cube.........................17
11. WPT accept marks of 5 subjects. Calculate total, percentage and acquired division.................17
12. WAP to accept basic salary and grade from user. Calculate and display net salary....................18

1|Page
Flow Chart and Pseudo code Swati Jain

1. Flow Chart Basic Diagrams

1. Start/End, Stop

2. Process

3. Input/Ouput

4. Decision Making

5. Connector

2|Page
Flow Chart and Pseudo code Swati Jain

2. If condition representation in flow chart

3|Page
Flow Chart and Pseudo code Swati Jain

3. Flow Chart showing condition statement

4|Page
Flow Chart and Pseudo code Swati Jain

4.Flow Chart and algo to find sum of 2 numbers.

Start Start

A=900, B=100
Read A,B

Sum = A+B Sum = 1000

Print Sum Print 1000

Stop
Stop

Algorithm
Step 1: Start
Step 2: Input A,B
Step 3: Sum <- A+B
Step 4: Print Sum
Step 5: Stop

5|Page
Flow Chart and Pseudo code Swati Jain

5. Flow Chart and algo to find the greater number


among 2 numbers.

Algorithm:

Step 1: Start

Step 2:Input A,B

Step3: If A>B then Print “ A is greater than B” else print “ B is greater than A”

Step 4: Stop

6|Page
Flow Chart and Pseudo code Swati Jain

6. Flow Chart and algo to calculate sum of first n


natural numbers.
i.e. 1+2+3+4+5+6+7+….+N.

For sum of Squares


on N natural
numbers:-
sum = sum + i*i

Print Sum

Algorithm :
Step 1: Start

Step 2: Input N

Step 3: Sum = 0 , product = 1

Step 4: For I <- 1 to N

Step 5: Sum <- Sum + I , product <- product * i

Step 6:# End of for loop

7|Page
Flow Chart and Pseudo code Swati Jain

Step 7: Print Sum , product

Step 8: Stop

Dry Run - N – 3

I Sum product N sqsum

1 1 1 3 1

2 3 2 3 5

3 6 6 3 14

Dry Run - N- 6

I Sum product N

1 1 1 6

2 3 2 6

3 6 6 6

4 10 24 6

5 15 120 6

6 21 720 6

Algorithm using while loop


Step 1: Start
Step 2: I<-1 , sum <- 0 , product <-1
Step 3: Input N
Step 4: While I <=N repeat steps 5 thru 6.
Step 5: Sum <- sum +I , product <- product *1
Step 6: I <- i+1
Step 7: print sum , product
Step 8: Stop

8|Page
Flow Chart and Pseudo code Swati Jain

Dry Run - N – 7

I sum productN

1 1 1 7
2 3 2 7
3 6 6 7
4 10 24 7
5 15 120 7
6 21 720 7
7 28 1540 7

9|Page
Flow Chart and Pseudo code Swati Jain

7. Flow Chart and algo to calculate area and perimeter


of a rectangle.

For Area and Perimeter of Square we


will take:-
Input Side->
Area = Side * Side ->
Perim = 4* Side.

Algorithm
Step 1: Start
Step 2: Input Length , Breadth
Step 3: Area <- Length * Breadth
Step 4: Print Area
Step 5: Perim <- 2* (Length + Breadth)
Step 6: Print Perim

10 | P a g e
Flow Chart and Pseudo code Swati Jain

Step 7: Stop

8. Algorithms
1. Calculate Base ^Power
Algorithm

For loop

Step 1: Start

Step 2: Input the Base and Power

Step 3: Product = 1

Step 4: For I <- 1 to Power

Step 5: Product = Product * base

Step 6:#End of for loop

Step 7: Print Product

Step 8: Stop

While Loop

Step 1: Start

Step 2: Input the Base and Power

Step 3: Product = 1

Step 4: i=1

Step 5: While I <= power repeat Step 6 through 7

Step 6: Product = Product * base

Step 7: i=i+1

Step 8: Print Product

Step 9: Stop

11 | P a g e
Flow Chart and Pseudo code Swati Jain

2. To print even numbers from 1 to N


Algorithm

Step 1: Start

Step 2: Input N

Step 3: i<-2

Step 3: while i<=N repeat 4 through 5

Step 4: print I

Step 5: i<- i+2

Step 5: Stop

3. To find max of three numbers.


Algorithm

Step 1: Start

Step 2: Read A,B,C

Step 3 : If A>B then

Step 4: If A>C then print “A is greater” Else Print “C is greater”

Step 5:else

Step 6: If B>C then print “B is greater” Else Print “C is greater”

Step 7: Stop

4. Check whether the number if positive or negative.


Algorithm

Step 1: Start

Step 2: Input A

Step 3:if A > 0 then Print” The number is positive”

Step 4: Else if 0>A then Print “ The number is negative”

Step 5: Stop

12 | P a g e
Flow Chart and Pseudo code Swati Jain

5. Check whether odd or even.


Algorithm

Step 1: Start

Step 2: Input A

Step 3: if A MOD 2 == 0 then Print “ A is an even number” else Print “ A is an odd number”

Step 4: Stop.

6. Print square of a number


Algorithm

Step 1: Start

Step 2: Input A

Step 3: square <- A*A

Step 4: Print Square

Step 5: Stop.

If x mod 2 != 0

13 | P a g e
Flow Chart and Pseudo code Swati Jain

7. Calculate Simple Interest


Interest = P x R x N/100

P – principal

R – rate of interest

N – no. of years.

Algorithm

Step 1: Start

Step 2: Input P,R,N

Step 3: interest <- P*R*N/100

Step 4: Print interest

Step 5: Stop.

14 | P a g e
Flow Chart and Pseudo code Swati Jain

8. Find the product of first n natural numbers.


For loop

Algorithm

Step 1: Start

Step 2: Input N

Step 3: product <- 1

Step 4: For i<- 1 to N

Step 5: product <- product * i

Step 6: # End for loop

Step 7: Print product

Step 8: Stop.

While loop

Algorithm

Step 1: Start

Step 2: Input N

Step 3: product <- 1 , I <- 1

Step 4: While i < N repeat steps 5 through 6

Step 5: product <- product * i

Step 6: I <- i+1

Step 7: Print product

Step 8: Stop.

15 | P a g e
Flow Chart and Pseudo code Swati Jain

9. Python Programs
9. Program to find whether a number is in the range

No 0-10 if no>=0 and no<=10 :

Else 10-20

Else 20-30

Else 30-40

Else >40

# Program to find range of a number

A = int (input (“Enter the number : “))

If A >=0 AND A <=10 :

Print “ In range 0-10”

Elif A > 10 AND A <=20 :

Print “ In range 10-20”

Elif A > 20 AND A <=30 :

Print “ In range 20-30”

Elif A > 30 AND A <=40 :

Print “ In range 30-40”

Else :

Print “ >40”

16 | P a g e
Flow Chart and Pseudo code Swati Jain

10. WPT print the square if the number entered is even,


otherwise print its cube.

11. WPT accept marks of 5 subjects. Calculate total, percentage


and acquired division
based on following criteria.

If perc>=60 division = first

If perc>=50 and less than 60

division = second

If perc>=40 and less than 50

division = third

If perc is less than 40

division= failed

If the student’s percentage is more

than 80%,

display “Eligible for scholar badge”

otherwise display “Not eligible “

17 | P a g e
Flow Chart and Pseudo code Swati Jain

12. WAP to accept basic salary and grade from user. Calculate
and display net salary.
if grade = ‘A’ - Hra=12% of basic,

da= 8% of basic

allow=500

pf = 10% of basic

if grade = ‘B’ - Hra=11% of basic

da= 6% of basic

allow=300

pf = 10% of basic

if grade = ‘C’ - Hra=9% of basic

da= 5% of basic

allow=200

pf = 10% of basic

net salary = basic salary + hra +da +allow-pf.

18 | P a g e

You might also like