You are on page 1of 3

Write a pseudocode algorithm to accept 15 numbers.

Calculate and print the


sum of the numbers. Also, display the 11th number entered followed by all the
numbers entered.
NUM

100 100 25
1 2 3 4 …. 15

BEGIN
DECLARE
Sum, x, AS INTEGER
ARRAY num[15] AS INTEGER

Sum  0

FOR x  1 TO 15 DO
PRINT “Enter a number”
READ num[x]
Sum  sum + num[x]
ENDFOR
PRINT “Sum of the numbers is:”, sum
PRINT “The 11th number entered is:”, num[11]
PRINT “The numbers entered are:”
FOR x  1 TO 15 DO
PRINT num[x]
ENDFOR
END
FOR x  15 DOWNTO 1 DO
PRINT num[x]
ENDFOR {Prints the numbers from bottom to top}

1. Write a pseudocode algorithm to accept 20 items and their prices.


Calculate and print the total of the items. Display each item with its price
to the user at the end.

BEGIN
DECLARE
X as integer
totalP As real
Array price[20] as real
Array itemname[20] string

totalP  0
FOR x  1 to 20 DO
Print “Enter the name and price of an item”
Read itemname[x], price[x]

totalP  totalP + price[x]


ENDFOR
Print “The names and prices are:”
FOR x  1 to 20 Do
Print Itemname[x], price[x]
ENDFOR
Print “total price of the items is”, totalP
END
2. Write a pseudocode algorithm to accept the age and name of 30
students in a class. Calculate and print the average age of the students.
At the end, the algorithm should print back the names and ages to the
user under the headings:
NAME AGE

You might also like