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

Algorithm Practice Sums Guide

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)
8 views2 pages

Algorithm Practice Sums Guide

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

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

Common questions

Powered by AI

Input the year, then check if it's divisible by 4 and not divisible by 100, unless it's also divisible by 400. If these conditions are met, print 'Leap Year'; otherwise, print 'Not a Leap Year' .

Input the number and check its value: if it's greater than zero, print 'Positive'; if less than zero, print 'Negative'; otherwise, print 'Zero' .

To convert Celsius to Fahrenheit, use the formula: Fahrenheit = (Celsius × 9/5) + 32. Input the temperature in Celsius, apply the formula, and display the result .

Input the age of the person. If the age is 18 or older, print 'Eligible to vote'; otherwise, print 'Not eligible' .

Input the number, then check if the remainder of the number when divided by 2 (n % 2) is zero; if so, print 'Even', otherwise print 'Odd' .

Input the number of units consumed and the rate per unit. Calculate the total bill using: Total Bill = units × rate per unit, and display the result .

Input the principal amount, rate of interest, and time period. Calculate the simple interest using: Simple Interest = (Principal × Rate × Time) / 100, and then display the result .

Input the rectangle's length and breadth. Calculate the area using the formula: Area = length × breadth, and the perimeter using: Perimeter = 2 × (length + breadth).

To calculate the average of five subject marks, input the marks of each subject and store them in variables a, b, c, d, e. Then, compute the average as avg = (a + b + c + d + e) / 5. Finally, display the average value .

Input the percentage and apply the following conditions: if percentage is 90 or above, assign 'Grade A'; if 75 or above but below 90, assign 'Grade B'; if 50 or above but below 75, assign 'Grade C'; otherwise, assign 'Grade D' .

You might also like