125k views
1 vote
How to write a pseudocode to read a sequence of numbers terminated by the number 999 and print the sum of the positive numbers and the product of the two numbers

1 Answer

5 votes

Answer:

The pseudocode (1) and (2) is as follows:

Pseudocode (1):

sum = 0

input n

while n ! = 999

if n > 0

sum+=n

Print sum

Pseudocode (2):

Input n1, n2

product = n1 * n2

Display product

Step-by-step explanation:

Pseudocode (1):

sum = 0 --- Initialize sum to 0

input n --- Input a number

while n ! = 999 --- The loop is repeated until 999 is entered

if n > 0 --- Check if n is positive

sum+=n --- Compute the sum, if true

input n --- Get another input

Print sum --- Print the calculated sum

Pseudocode (2):

Input n1, n2 --- Get input for both numbers

product = n1 * n2 --- Compute their products

Display product --- Print the calculated product

User Natan Williams
by
3.3k points