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 the logic for a program that allows a user to enter 10 numbers, stores the...
Design the logic for a program that allows a user to enter 10 numbers, stores the numbers in an array, then displays all of the numbers, the largest number, and the smallest.  create a solution algorithm using pseudocode  create a flowchart
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.
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!!!!*
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?
Write a program in MIPS Assembly. This program will ask the user to enter 20 numbers....
Write a program in MIPS Assembly. This program will ask the user to enter 20 numbers. The program will store these numbers in an array in memory (sequential memory locations). It will then print out the list of numbers in three different formats: The numbers will be printed each on a separate line. The numbers will be printed on a single line, with spaces between the numbers. The program will ask the user to enter a number n. The program...
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...
Program must be in C Write a program that allows the user to enter the last...
Program must be in C Write a program that allows the user to enter the last names of five candidates in a local election and the number of votes received by each candidate in two different arrays. The program should then output each candidate’s name, the number of votes received, and the percentage of the total votes received by the candidate. Your program should also output the winner of the election. Example (Letters and numbers with underscore indicate an input):...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT