1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Sep 2011
Posts
1
Rep Power
0

#### Pseudocode help

Can someone help me write the following in pseudocode for my computer science ?? I am new to programming and this would help me a lot
The expected behavior of the program is as follows.

1.The program informs the user that it will compute the sum of a 0-terminated sequence of numbers.
2.The program prompts the user for each number.
3.The user inputs each number, one at a time.
4.Each number given by the user is added to a running total.
5.When the user gives 0 as input, the program finishes by displaying "The sum is " followed by the sum of all numbers entered by the user.
Write an algorithm to compute the sum of a 0-terminated sequence of numbers given by the user.
2. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Sep 2011
Posts
2
Rep Power
0
I believe this algorithm can be written in this way;

1.Declare the number n //which is the input from the keyboard.
2.Declare the sum and initialise it to zero.
3.Compute the sum
do
begin
input number n.
increment sum with n
endwhile number n is equals to zero
end
4.Display the sum.
3. True pseudocode is closer to:
Code:
```print "Enter numbers when prompted. Entering a zero will cause the SUM of all numbers to be displayed."
sum = 0;
while (get_entry() != 0 ) {
sum += entry();
}
print "The sum is ", sum;
exit;```
If you weren't able to do this yourself, you need to ask your professor or TA for help. This is a very basic example of program flow, not grasping it means you'll be lost for the rest of the semester.

-Dan