0% found this document useful (0 votes)
16 views2 pages

Algorithm Practice Sums

Sums on algorithm in computer
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

Algorithm Practice Sums

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

Algorithm Practice Sums [Without Conditions]

Question 1: Write an algorithm to input the marks of 5 subjects and calculate and display the average
marks.

Ans: Algorithm:

 Step 1: Start

 Step 2: Read marks for 5 subjects and store in a, b, c, d, e

 Step 3: Calculate average, avg = (a + b + c + d + e) / 5

 Step 4: Print "Average =", avg

 Step 5: Stop

Question 2: Write an algorithm to input the length and breadth of a rectangle and calculate

and display its area and perimeter.

Formulas:

 Area = length × breadth

 Perimeter = 2 × (length + breadth)

Question 3 : Write an algorithm to input the principal, rate of interest, and time from the user and
calculate and display the simple interest.
Formula:
Simple Interest = (P × R × T) / 100

Question 4: Write an algorithm to input the radius of a circle and calculate and display its area and
circumference.
Formulas:

 Area = π × r²

 Circumference = 2 × π × r
(Use π ≈ 3.14)

Question 5: Write an algorithm to input the base and height of a triangle and calculate and display its
area.
Formula:
Area = (base × height) / 2

Question 6: Write an algorithm to input temperature in Celsius and convert it to Fahrenheit.


Formula:
Fahrenheit = (Celsius × 9/5) + 32

Question 7: Write an algorithm to input the number of units consumed and calculate the total
electricity bill using a fixed rate per unit.
Formula:
Total Bill = units × rate per unit
Algorithm Practice Sums [With Conditions]

Question 1: Write an algorithm to input a number and display whether it is positive, negative, or zero.
Conditions:

 If n > 0 → Positive

 Else if n < 0 → Negative

 Else → Zero

Ans: Algorithm:

Step 1: Start

Step 2: Read a number a

Step 3: If a > 0, go to Step 4; otherwise, go to Step 5

Step 4: Print "It is a Positive Number" → Go to Step 8

Step 5: If a < 0, go to Step 6; otherwise, go to Step 7

Step 6: Print "It is a Negative Number" → Go to Step 8

Step 7: Print "It is Zero"

Step 8: Stop

Question 2: Write an algorithm to input a number and check whether it is even or odd.
Condition:

 If n % 2 == 0 → Even

 Else → Odd

Question 3 : Write an algorithm to input the age of a person and check if the person is eligible to vote
(18 years or older).
Condition:

 If age >= 18 → Eligible to vote

 Else → Not eligible

Question 4 : Write an algorithm to input a year and check whether it is a leap year.
Conditions:

 If (year % 4 == 0 and year % 100 != 0) or (year % 400 == 0) → Leap Year

 Else → Not a Leap Year

Question 5: Write an algorithm to input a percentage and assign a grade based on the following
criteria.
Conditions:

 If percentage >= 90 → Grade A

 Else if percentage >= 75 → Grade B

 Else if percentage >= 50 → Grade C

 Else → Grade D

You might also like