Notes to develop flow charts ++
Notes to develop flow charts ++
AIM:
To develop an algorithm and flowchart for calculating the Weight of a Steel Bar.
ALGORITHM:
Step 1: Start
W=D^2×L/162
Step 6: Stop
FLOWCHART:
OUTPUT:
Test Case Length (meters) Diameter (mm) Weight (kg) Weight (kg)
1 10 5 1.54
2 20 8 7.90
3 15 10 9.26
4 5 12 4.44
RESULT:
Thus, the algorithm and flowchart for calculating the Weight of a Steel Bar were designed
and verified successfully.
EX. NO.: 1b COMPUTE ELECTRICAL CURRENT IN THREE PHASE AC CIRCUIT
AIM:
ALGORITHM:
Step 1: Start
RESULT:
Thus, the algorithm and flowchart for computing Electrical Current in 3 Phase AC Circuit
were designed and verified successfully.
EX. NO.: 1c WEIGHT OF A MOTORBIKE
AIM:
ALGORITHM:
Step 1: Start
Step 3: If bike_type = "Chopper", print "A Chopper weighs about 315 kg."
Step 4: If bike_type = "Sport bike", print "A Sport bike weighs about 180 kg."
Step 5: If bike_type = "Scooter", print "A Scooter weighs about 115 kg."
Step 6: Otherwise, print "Sorry, I don't have information on that bike type."
Step 7: Stop
FLOWCHART:
OUTPUT:
RESULT:
Thus, the algorithm and flowchart for finding the Weight of a Motorbike were designed and
verified successfully.
EX. NO.: 1d RETAIL SHOP BILLING
AIM:
ALGORITHM:
Step 1: Start
Step 2: Get the product name PROD1.
Step 3: Get the quantity Q1 of PROD1.
Step 4: Get the price P1 of product PROD1.
Step 5: Get the product name PROD2.
Step 6: Get the quantity Q2 of product PROD2.
Step 7: Get the price P2 of product PROD2.
Step 8: Get the product name PROD3.
Step 9: Get the quantity Q3 of product PROD3.
Step 10: Get the price P3 of product PROD3.
Step 11: Calculate the total price of all products:
TOTALPRICE = (Q1×P1) + (Q2*P2) + (Q3*P3)
Step 12: If TOTALPRICE > 1000, then:
Calculate the discount as 10% of TOTALPRICE:
DISCOUNT=TOTALPRICE× 10/100
Step 13: Else, if TOTALPRICE <= 1000, then:
Calculate the discount as 5% of TOTALPRICE:
DISCOUNT=TOTALPRICE× 5/ 100
Step 14: BILL=TOTALPRICE−DISCOUNT
Step 15: Display the value of the final bill (BILL).
Step 16: Stop.
FLOWCHART:
OUTPUT:
PROD1 = A, P1 = 200, Q1 =
2,
1 PROD2 = B, P2 = 500, Q2 = 903
1,
PROD3 = C, P3 = 50, Q3 = 1
PROD1 = PEN, P1 = 50, Q1 =
2,
PROD2 = PENCIL, P2 = 25,
2 3240
Q2 = 100,
PROD3 = PAPER, P3 = 10,
Q3 = 100
PROD1 = LAPTOP, P1 =
50000, Q1 = 1,
PROD2 = MOUSE, P2 =
3 48600
1000, Q2 = 2,
PROD3 = KEYBOARD, P3 =
2000, Q3 = 1
PROD1 = RICE, P1 = 40, Q1 =
10,
PROD2 = WHEAT, P2 = 30,
4 990
Q2 = 15,
PROD3 = SUGAR, P3 = 50,
Q3 = 5
RESULT:
Thus, the solution for Retail shop bill generation problem is arrived, an algorithm and
flowchart were designed and verified successfully.
EX.NO.: 1e ELECTRICITY BILL
AIM:
ALGORITHM:
Step 1: Start.
Step 2: Get the value of number of unit's power consumed from the user and store it in "Unit".
Step 3: Check the value of "Unit". If it is less than or equals to 100 then go to Step 3.1.
Otherwise go to Step 4.
Fixed_Charge = 0
Energy_Charge = 0
Step 4: If the value of "Unit" is lesser than or equals to 200 then go to Step 4.1.
Otherwise go to Step 5.
Fixed_Charge = 20
Energy_Charge = (Unit-100)*1.5
Step 5: If the value of "Unit" is lesser than or equals to 500 then go to Step 5.1.
Otherwise go to Step 6.
Fixed_Charge = 30
Step 6: For the remaining values of "Unit" perform the below calculation.
Fixed_Charge=30
Energy_Charge= (Unit-500)*6.6 + (300*4.6) + (100*3.5)
Step 8: Stop.
FLOWCHART:
OUTPUT:
1 50 0
2 150 95
3 250 380
4 600 2420
RESULT:
Thus, the algorithm and flowchart for calculating electricity bill were designed and verified
successfully.
EX. NO.: 1f SINE SERIES
AIM:
ALGORITHM:
Step 1: Start
Step 3: Convert the angle from degrees to radians using the formula:
Step 7: Initialize i = 1.
sum=sum+term
Increment i by 1.
1 30 4 0.4999
2 45 3 0.7071
3 -45 6 -0.7071
4 60 7 0.8660
RESULT:
Thus, the algorithm and flowchart for the Sine Series were designed and verified successfully.
EX. NO.: 2a EXCHANGE THE VALUES OF TWO VARIABLES
AIM:
ALGORITHM:
Step 1: Start
Step 2: Get the values of a and b
Step 3: temp=a
Step 4: a=b
Step 5: b=temp
Step 6: Display a and b
Step 7: Stop
FLOWCHART:
PROGRAM:
OUTPUT:
Actual Output
Expected Output Expected Output
Test Case Input Values Before Swapping After Swapping After Swapping
1 a = 5, b = 10 a = 5, b = 10 a = 10, b = 5
2 a = -3, b = 7 a = -3, b = 7 a = 7, b = -3
3 a = 0, b = 1 a = 0, b = 1 a = 1, b = 0
Result:
Thus, the python program to swap two input numbers was implemented and verified
successfully.
EX. NO.: 2b SUM OF FIRST N NATURAL NUMBERS
AIM:
ALGORITHM:
Step 1: Start
Step 2: Get the value of n
Step 3: Initialize the variables as follows:
i=1
sum = 0
Step 4: If i<= n then go to step 5 otherwise, go to step 7
Step 5: Sum=sum+i
Step 6: i = i +1
Step 7: Go to step 4
Step 8: Display the value of sum
Step 9: Stop
FLOWCHART:
PROGRAM:
OUTPUT:
Result:
Thus, the python program to calculate the sum of first n natural numbers was implemented
and verified successfully.
EX. NO.: 2C DISTANCE BETWEEN TWO POINTS
AIM:
ALGORITHM:
Step 1: Start
Step 2: Get the values of x1, y1, x2 and y2.
Step 3: Calculate the distance between two points using the following expression
distance = (𝑥2 − 𝑥1) + (𝑦2 − 𝑦1)
Step 4: Display the value of distance
Step 5: Stop
FLOWCHART:
PROGRAM:
import math
xl=int(input("enter x1"))
yl=int(input("enter y1"))
x2=int(input("enter x2"))
y2=int(input("enter y2"))
distance = math.sqrt(((x2-x1)**2)+((y2- y1)**2))
print(distance)
OUTPUT:
Result:
Thus, the python program to calculate the distance between two points was implemented
and verified successfully.
EX. NO.: 3a NUMBER SERIES
AlM:
ALGORITHM:
Step 1: Start
Step 2: Get the values of x and n.
Step 3: Initialize s = 0, i = 0
Step 4: If i<=n, then go to step 5. Otherwise go to step 8
Step 5: s=s+x**i
Step 6: i = i+1
Step 7: Go to step 4.
Step 8: Display the value of s.
Step 9: Stop
PROGRAM:
OUTPUT:
1 x = 2, n = 3 15
2 x = 1, n = 5 6
3 x = 3, n = 2 13
RESULT:
Thus, the python program to find the sum of series was implemented and verified
successfully.
EX. NO.: 3b NUMBER PATTERNS
AIM:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
ALGORITHM:
Step 1: Start
Step 2: Get the number of rows in pattern, n.
Step 3: Create a nested loop as follows:
for i = 0 to n-1
for j = 0 to i+1
display j+1
Step 4: Stop
PROGRAM:
OUTPUT:
1
1 n=3 1 2
1 2 3
1
1 2
2 n=5 1 2 3
1 2 3 4
1 2 3 4 5
RESULT:
Thus, the python program to find the to print number patterns was implemented and
verified successfully.
EX. NO.: 3c PYRAMID PATTERN
AIM:
*
* *
* * *
* * * *
* * * * *
ALGORITHM:
Step 1: Start
Step 2: Get the number of rows, num
Step 3: Create a nested loop as follows:
for i = 0 to num-1
for j = 0 to num-i-1
display “ “
for j = 0 to i+1
display “*”
Step 4: Stop
PROGRAM:
num=int (input ("Enter the number of rows:"))
for i in range(0,num) :
for j in range(0,num-i-1):
print (end=" ")
for j in range(0,i+1):
print ("*",end=" ")
print ()
OUTPUT:
Input Value
Test Case Expected Output Actual Output
Enter the number of rows:
*
1 3 * *
* * *
*
* *
* * *
2 5
* * * *
* * * * *
RESULT:
Thus, the python program to find the to print pyramid pattern was implemented and
verified successfully.