Question

In: Computer Science

Design the logic for a program that allows a user to enter 20 numbers, then displays...

Design the logic for a program that allows a user to enter 20 numbers, then displays them in the reverse order of entry.

Design the logic for a program that allows a user to enter 20 numbers, then displays each number and its difference from the numeric average of the numbers entered.

The program is C++. I need a Pseudocode

Solutions

Expert Solution

Code (first one)

#include<iostream>
using namespace std;

int main()
{
    int a[20]; // create array of 20 elements
    for(int i=0;i<20;i++)
    {
        cin>>a[i];
    }
    cout<<"values in reversed order\n";
    for(int i=19;i>=0;i--)
    {
        cout<<a[i]<<" ";
    }
    return 0;
}

Pseudocode (first one)

  • create array a with 20 elements.
  • for i 0 to 20(20 exclusive) ,get user input and store input as a[i]
  • for i 19 to 0(0 inclusive) print a[i]

Code(second one)

#include<iostream>
#include<cstdlib>
using namespace std;

int main()
{
    int a[20]; // create array of 20 elements
    for(int i=0;i<20;i++)
    {
        cin>>a[i];
    }
    int sum=0;
    for(int i=0;i<20;i++)
    {
        sum=sum+a[i];
    }
    cout<<"number and thier difference with avg\n";
    int avg=sum/20;
    for(int i=0;i<20;i++)
    {
        cout<<a[i]<<" "<<abs(a[i]-avg)<<"\n";
    }
    return 0;
}

Pseudocode

  • create array a with 20 elements
  • for i to 20 get user input and store it as a[i]
  • sum=0
  • for i to 20(20 exclusive), sum =sum+a[i]
  • avg=sum/20
  • for i to 20(20 exclusive), print a[i] abs(a[i]-avg)

Terminal Work(first one)

Terminal Work(second one)

.


Related Solutions

Design a complete program that asks the user to enter a series of 20 numbers. The...
Design a complete program that asks the user to enter a series of 20 numbers. The program should store the numbers in an array and then display each of the following data: I. The lowest number in the array II. The highest number in the array III. The total of the numbers in the array IV. The average of the numbers in the array *PYTHON NOT PSUEDOCODE AND FLOW CHART!!!!*
Using Pseudocode: Design a program that allows the user to enter 20 names into a String...
Using Pseudocode: Design a program that allows the user to enter 20 names into a String array. Sort the array in ascending (alphabetical) order and display its contents.
Write a C++ program that asks the user to enter in three numbers and displays the...
Write a C++ program that asks the user to enter in three numbers and displays the numbers in ascending order. If the three numbers are all the same the program should tell the user that all the numbers are equal and exits the program. Be sure to think about all the possible cases of three numbers. Be sure to test all possible paths. Sample Runs: NOTE: not all possible runs are shown below. Sample Run 1 Welcome to the order...
Design a modular program which asks the user to enter a list of numbers. The numbers...
Design a modular program which asks the user to enter a list of numbers. The numbers must be stored in an array. The program then finds the index of the first occurrence of the smallest element in the array and the last occurrence of the largest element in the array. The program displays the position and value of each of these items.
Design the logic for a program that has two parts: The user enters 15 numbers that...
Design the logic for a program that has two parts: The user enters 15 numbers that are stored into an array. The program uses the array to display the numbers back to the user in reverse order. You must use an array and one or more loops to get full credit. Can someone please help me figure this out?
can someone please check this code? – Enter Quantity of Numbers Design a program that allows...
can someone please check this code? – Enter Quantity of Numbers Design a program that allows a user to enter any quantity of numbers until a negative number is entered. Then display the highest number and the lowest number. For the programming problem, create the pseudocode and enter it below. Enter pseudocode here start     Declarations           num number           num high             num low              housekeeping()     while number >=0 detailLoop()      endwhile      finish() stop housekeeping( )           output...
Create a Python program that: Allows the user to enter a phrase or sentence. The program...
Create a Python program that: Allows the user to enter a phrase or sentence. The program should then take the phrase or sentence entered Separate out the individual words entered Each individual word should then be added to a list After all of the words have been place in a list Sort the contents of the list Display the contents of the sorted list with each individual word displayed on a separate line Display a message to the user indicating...
Write a program that runs on SPIM that allows the user to enter the number of...
Write a program that runs on SPIM that allows the user to enter the number of hours, minutes and seconds and then prints out the total time in seconds. Name the source code file “seconds.asm
Write a program that runs on SPIM that allows the user to enter the number of...
Write a program that runs on SPIM that allows the user to enter the number of hours, minutes and seconds and then prints out the total time in seconds. Name the source code file “seconds.asm Explain step by step
Using Java, design a program to let user enter two lists of numbers within the range...
Using Java, design a program to let user enter two lists of numbers within the range [0, 9] from keyboard, you could either use flag to denote end of the list or ask user to enter the list size first and then enter the list numbers. Each of these two lists represents a set (keep in mind that duplicate elements are not allowed in the same set but are allowed between sets), so we have two sets A and B....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT