Ask questions and get helpful answers.
Ask a New Question

Design the logic for a program that allows a user to enter any amount of numbers up to 10 or until a sentinal

value of -1 is entered.

Then the program displays the count of the numbers entered and numeric average of
the numbers (not including the -1 of course).

After display the average of all the entered numbers, the
program will then display each number and its difference from that average.

  1. 👍
  2. 👎
  3. 👁
  4. ℹ️
  5. 🚩

1 answer

  1. x=0
    i=0
    sum=0
    while x ≠ -1
    read x
    if x ≠ -1 { v[++i] = x; sum+=x }
    end while

    print i
    if i==0 exit

    avg = sum/i
    print avg
    for j=1..i print v[j],v[j]-i

    you can add any labels you see fit for user interaction.

    1. 👍
    2. 👎
    3. ℹ️
    4. 🚩

Answer this Question

Related Questions

Still need help?

You can ask a new question or browse existing questions.