Asked by amare melak
HOW TO write algorithm and pseudocode
TO find the avrge,max min and sum of three number given by the user
TO find the avrge,max min and sum of three number given by the user
Answers
Answered by
Bot
Algorithm:
1. Start
2. Declare variables num1, num2, num3, sum, avg, max, min
3. Read values of num1, num2 and num3 from user
4. Initialize sum as num1 + num2 + num3
5. Calculate avg as sum/3
6. Set max as num1
7. If num2 > max, set max as num2
8. If num3 > max, set max as num3
9. Set min as num1
10. If num2 < min, set min as num2
11. If num3 < min, set min as num3
12. Print sum, avg, max and min
13. Stop
Pseudocode:
DECLARE num1, num2, num3, sum, avg, max, min
READ num1, num2, num3
SET sum = num1 + num2 + num3
SET avg = sum/3
SET max = num1
IF num2 > max THEN SET max = num2
IF num3 > max THEN SET max = num3
SET min = num1
IF num2 < min THEN SET min = num2
IF num3 < min THEN SET min = num3
PRINT "Sum=",sum
PRINT "Average=",avg
PRINT "Maximum=",max
PRINT "Minimum=",min
1. Start
2. Declare variables num1, num2, num3, sum, avg, max, min
3. Read values of num1, num2 and num3 from user
4. Initialize sum as num1 + num2 + num3
5. Calculate avg as sum/3
6. Set max as num1
7. If num2 > max, set max as num2
8. If num3 > max, set max as num3
9. Set min as num1
10. If num2 < min, set min as num2
11. If num3 < min, set min as num3
12. Print sum, avg, max and min
13. Stop
Pseudocode:
DECLARE num1, num2, num3, sum, avg, max, min
READ num1, num2, num3
SET sum = num1 + num2 + num3
SET avg = sum/3
SET max = num1
IF num2 > max THEN SET max = num2
IF num3 > max THEN SET max = num3
SET min = num1
IF num2 < min THEN SET min = num2
IF num3 < min THEN SET min = num3
PRINT "Sum=",sum
PRINT "Average=",avg
PRINT "Maximum=",max
PRINT "Minimum=",min