You are on page 1of 4

1. Write an algorithm that computes for the average of three scores.

Start

Input num1 num2.


And num3

Compute for the sum of n1 + n2 + n3

Sum = n1 + n2 + n3

Average = Sum ÷ 3

Print Average

End

2. Write an algorithm that accepts time in seconds then display in hour/s, minute/s,
second/s equivalent.

Start

enter 2 hr, 2 min and 2 sec

enter 2 hr = 7200 sec


enter 2 min = 120 sec
enter 2 sec = 2 sec

Print 2hr, 2min ,


2sec;

End
3. Accept three numbers and display in ascending order.

Start

enter 1, 2, 3

1>2

2>3 2>3

Print Print
1, 2, 3 2, 1, 3
1>3 2>3

Print Print Print Print


1, 3, 2 3, 1, 2 2, 3, 1 3, 2, 1

End
4. Write an algorithm to check whether a number is prime or not.

Start

Declare n, I and flag

Flag = 1, I = 2

Read n

If flag = 0

I=I+1

Print prime
If n/I = 1 num

Print not End


prime num
5. Write an algorithm to find the Greatest Common Divisor (GCD) of two numbers.

Start

input num 1, num 2

Is num1 = num 2

Is num1 >
num2

n1 = n1 – n2 n1 = n1 – n2

Print n1

End

You might also like