'Having trouble in writing basic pseudocode
Write a pseudocode that will compute and print the products of N integers.
Hint: N is the limit of your loop. For example,
while y <= N: product = product * y
I don't get the problem so I can't think of anything, I am new to this.
Solution 1:[1]
PRINT("N = __") // Asks the user to input what "n" is
n <-- INT(USERINPUT) // The answer must be an integer (non-decimal). It saves this to the variable "n".
y <-- [] // Makes a blank array called "y"
FOR n: // Allows the below code to run as a maximum, "n" times. It's a loop, so repeats.
PRINT("Add the number: ") // Asks the user to input an integer
input <-- (USERINPUT) // For the first iteration (loop), it saves the answer to "y", but for the other loops, it replaces the previous value
IF input == "break" THEN: // If the user answered "break" - it is case-sensitive.
? print (y) // Prints our array with our integers
break // Ends the code
ELSE: // If the user did not answer "break".
y.append(input) // Appends (adds) our answer to the array "y"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | taylor.2317 |
