115k views
0 votes
Write a pseudo-code to find the sum of

numbers divisible by 4. The pseudo-code must
allow the user to accept a number and add it to
the sum if it is divisible by 4. It should continue
accepting numbers as long as the user wants
to provide an input and should display the final
sum.
Note: You can drag and drop the pseudo-code
magnets to the pseudo-code step boxes and
create the appropriate pseudo-code.

User Sikachu
by
7.4k points

1 Answer

3 votes

Final answer:

To find the sum of numbers divisible by 4, use a loop to accept numbers and add them to the sum if divisible by 4. Display the final sum.


Step-by-step explanation:

To find the sum of numbers divisible by 4, you can use a loop to continuously accept numbers and check if they are divisible by 4. Here is the pseudo-code:

  1. Initialize a variable 'sum' to 0.
  2. Initialize a variable 'userInput' to 0.
  3. Start a loop:
    • Ask the user for a number.
    • Accept the number as 'userInput'.
    • If 'userInput' is divisible by 4, add it to the 'sum'.
    • Ask the user if they want to continue.
    • If the user wants to continue, repeat the loop. Otherwise, exit the loop.
  4. Display the final 'sum'.
This pseudo-code will repeatedly prompt the user for numbers, add the ones divisible by 4 to the sum, and keep a running total until the user chooses to stop. Finally, it will display the final sum.

Learn more about sum of numbers divisible by 4

User Anika
by
7.9k points