0% found this document useful (0 votes)
4 views

Algorithms Updated

The document outlines a series of practical programming exercises that cover basic mathematical calculations, geometric volume computations, temperature conversions, profit and loss analysis, grade determination, number classification, and electricity billing. Each practical includes a step-by-step algorithm detailing variable declaration, input reading, calculations, and output procedures. The exercises are designed to enhance understanding of fundamental programming concepts and logical flow.

Uploaded by

itzmuzainasohaib
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Algorithms Updated

The document outlines a series of practical programming exercises that cover basic mathematical calculations, geometric volume computations, temperature conversions, profit and loss analysis, grade determination, number classification, and electricity billing. Each practical includes a step-by-step algorithm detailing variable declaration, input reading, calculations, and output procedures. The exercises are designed to enhance understanding of fundamental programming concepts and logical flow.

Uploaded by

itzmuzainasohaib
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Practical #1: To find the sum, product, and average of five given

numbers

Step 1: start
Step 2: Declare the variables a, b, c, d, e, sum, prod, avg
Step 3: Read the value of a, b, c, d, e
Step 4: calculate sum, product and average
sum=a+b+c+d+e;
prod=a*b*c*d*e;
avg=sum/5;
Step 5: output sum, prod, avg
Step 6: stop
Practical #2: To find acceleration of a moving object with given mass
and the force applied.
Step 1: start
Step 2: Declare the variables mass, force, a
Step 3: Read the value of mass and force
Step 4: calculate acceleration
a= (force/mass);
Step 5: output a
Step 8: stop

Practical #3: To Find the volume of a Cube, Cylinder or Sphere


Volume of Cube:
Step 1: start
Step 2: Declare the variables side, volume
Step 3: Read the value of side
Step 4: calculate volume
Volume=side *side*side
Step 5: output volume
Step 6: stop
Volume of Cylinder:
Step 1: start
Step 2: Declare the variables height, radius, pi=3.142, volume
Step 3: Read the value of height and radius
Step 4: calculate volume
Volume = pi * (radius * radius) * height;
Step 5: output volume
Step 6: stop

Volume of Sphere:
Step 1: start
Step 2: Declare the variables r, volume
Step 3: Read the value of r
Step 4: calculate volume
Volume= (4/3.0) *3.14*r*r*r;
Step 5: output volume
Step 6: stop

Practical #4: To find the area of a triangle, parallelogram,

rhombus and trapezoid

Area of Triangle:
Step 1: start
Step 2: Declare the variables base, height, area
Step 3: Read the value base and height
Step 4: calculate area
area= (base * height) / 2;
Step 5: output area
Step 6: stop
Area of Parallelogram:
Step 1: start
Step 2: Declare the variables base, height, area
Step 3: Read the value base and height
Step 4: calculate area
area= height * base;
Step 5: output area
Step 6: stop
Area of Rhombus:
Step 1: start
Step 2: Declare the variables d1, d2, area
Step 3: Read the value d1 and d2
Step 4: calculate area
area = (d1 * d2) / 2;
Step 5: output area
Step 6: stop
Area of Trapezoid:
Step 1: start
Step 2: Declare the variables base1, base2, height, area
Step 3: Read the value base1, base2, height
Step 4: calculate area
area = ((base1+base2)/2) *height;
Step 5: output area
Step 6: stop
Practical #5: To convert Celsius to Fahrenheit temperature and vice
versa
Step 1: start
Step 2: Declare the variables Fahrenheit, Celsius
Step 3: Read the value of Fahrenheit
Step 4: calculate Celsius
Celsius = (Fahrenheit - 32) *5/9;
Step 5: output Celsius
Step 8: stop
To convert Fahrenheit into Centigrade
Step 1: start
Step 2: Declare the variables Fahrenheit, Celsius
Step 3: Read the value of Celsius
Step 4: calculate Fahrenheit
Fahrenheit = (Celsius *9/5) +32;
Step 5: output Celsius
Step 8: stop

Practical #6: Calculate the profit, loss, profit percentage and loss
percentage of a business.
Step 1: start
Step 2: Declare the variables cp, sp, profit, loss, profit_per, loss_per
Step 3: Read the value of cp and sp
Step 4: check for condition
If sp > cp then goto step 5 otherwise goto step 7
Step 5: profit=sp-cp
profit_per=(profit*100)/cp
Step 6: output profit, profit_per
goto step 11
Step 7: check for condition
If cp > sp then goto step 8 otherwise goto step 10
Step 8: loss=cp-sp
loss_per=(loss*100)/cp
Step 9: output loss, loss_per
goto step 11
Step 10: output No profit No Loss
Step 11: stop
Practical #7: To Calculate the grades of students on the basis of
marks. The score sheet should contain name of the student, father’s
name and class.
Step 1: start
Step 2: Declare the variable name, f_name, clas, marks
Step 3: Read the value of name, f_name, clas, marks
Step 4: check if condition
If marks<0 or marks>100 then output “wrong entry” goto step 12 otherwise
goto step 5
Step 5: check if condition
If marks<33 then output “Grade F” goto step 12 otherwise goto step 6
Step 6: check if condition
If marks>33 and marks<40 then output “Grade E” goto step 12 otherwise
goto step 7
Step 7: check if condition
If marks>40 and marks<50 then output “Grade D” goto step 12 otherwise
goto step 8
Step 8: check if condition
If marks>50 and marks<60 then output “Grade C” goto step otherwise
goto step 9
Step 9: check if condition
If marks>60 and marks<70 then output “Grade B” goto step 12 otherwise
goto step 10
Step 10: check if condition
If marks>70 and marks<80 then output “Grade A” goto step otherwise
goto step 11
Step 11: Output “Grade A1”
Step 12: stop
Practical #8: To Show whether a number is positive, negative or zero.
Step 1: start
Step 2: Declare the variables x
Step 3: Read the value of x
Step 4: check if condition
If x<0 then goto step 5 otherwise goto step 6
Step 5: output Number is Negative: goto step 9
Step 6: check if condition
If x>0 then goto step 7 otherwise goto step 8
Step 7: output Number is Positive: goto step 9
Step 8: output Number is 0
Step 9: stop
Practical #9a: To find the maximum number from input values
Step 1: start
Step 2: Declare the variables n, I, number, max=0
Step 3: Read the value of n
Step 4: check for condition
If i<=n then goto step 5 otherwise goto step 7
Step 5: read the value of number
Step 6: check the condition
If number>max then max=number goto step 5 otherwise goto step 6
Step 6: output max
Step 7: stop

Practical #9b: To find the minimum number from input values


Step 1: start
Step 2: Declare the variables n, I, number, min=32767
Step 3: Read the value of n
Step 4: check for condition
If i<=n then goto step 5 otherwise goto step 7
Step 5: read the value of number
Step 6: check the condition
If number<min then min=number goto step 5 otherwise goto step 6
Step 6: output min
Step 7: stop
Practical #10: To Show whether a number is even or odd.
Step 1: start
Step 2: Declare the variables x
Step 3: Read the value of x
Step 4: check if condition
If x%2=0 then output Number is Even otherwise output Number is odd
Step 5: stop
Practical #11: To Prepare an electricity bill
Step 1: start
Step 2: Declare the variables bill, units
Step 3: Read the value of units
Step 4: compare the units
If units<=50 && units>=0 then Bill=units * 3.50 otherwise goto step 7
Step 5 Output bill
Step 6: goto step 15
Step 7: compare the units
If units<=100 && units>=0 then Bill=units * 4 otherwise goto step 10
Step 8: Output bill
Step 9: goto step 15
Step 10: compare the units
If units<=250 && units>=0 then Bill=units * 5.20 otherwise goto step 13
Step 11: Output bill
Step 12: goto step 15
Step 13: compare the units
If units>=250 then Bill=units * 6.50 otherwise display enter valid units
Goto step 15
Step 14: Output bill
Step 15: stop
Practical #12: To determine whether a given number is prime or not
Step 1: start
Step 2: Declare the variables n, I, p
Step 3: Read the value of n
Step 4: check if condition
If n=0 or n=1 then p=1
Step 5: check for condition
If i<=n/2 then goto step 6 otherwise goto step 7
Step 6: check if condition
If n%i =0 then p=1 otherwise goto step 7
Step 7: check the condition
If p=0 then output “prime number” otherwise output” not a prime number”
Step 8: stop

You might also like