Question
use C++ programming language and follow the instruction carefully. thanks!



Inputs: . [integer] values (10 times) Outputs: • [integer) highest value . [integer] lowest value Description: Write a progra
Do not find the highest and lowest as the user enters data, find them from the array after all 10 values have been entered Sa
0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include<iostream>
using namespace std;
//Execution begins here
int main()
{
    //Declaring integer array of arr with size 10
    int arr[10];
    //loop to insert elements in array of index i
    for(int i=0;i<10;i++)
    {
        //Asking the user to enter i+1th element array starts from index 0 
    cout<<"Enter an integer value ("<<i+1<<"): ";
    //Storing elements in array index i
    cin>>arr[i];
    }
    //Display "You entered: "
    cout<<"You entered: ";
    //loop to print elements in array of position i with ',' until 9th element
    for(int i=0;i<9;i++)
    {
        //Printing array value in index i with ','
        cout<<arr[i]<<", ";
    }
    //Displaying last element without ','
    cout<<arr[9];
    //Set lowest as first element of array
    int lowest=arr[0];
    //Set highest as first element of array
    int highest=arr[0];
    //loop to access elements in array of index i
    for(int i=1;i<10;i++)
    {
        //Checking if array element in i'th index is less than lowest
        if(arr[i]<lowest)
        //Set lowest as ith element of array
            lowest=arr[i];
        //Checking if array element in i'th index is greater than highest
        if(arr[i]>highest)
        //Set highest as ith element of array
            highest=arr[i];
    }
    //Printing highest value
    cout<<"\nThe highest value: "<<highest;
    //Printing lowest value
    cout<<"\nThe lowest value: "<<lowest;
    //Prompting the user to enter a key toterminate 
    cout<<"\nPress any key to continue...\n";
    //Reading  a user entered character you can remove next two lines if you dont want it
    char c;
    cin>>c;
    return 0;
}

Sample Output

PS F:\chegcpp> cd f: cheg|cpp\; if ($?) { g+ Largesmal rray } Enter an integer value (1): 24 Enter an integer value (2): 29

토 6 8 G# Birthday Calc.cpp GSList.cpp G+ Large SmallArray.cpp X G+ LinkedQueue.cpp G+ LargeSmallArray.cpp > main 1 #include<i

1/ CL TUNCOL a III SL CICHICIIL VI аттау go G+ Birthday Calc.cpp G+ SList.cpp G+ Large SmallArray.cpp X G+ LinkedQueue.cpp G+

Add a comment
Know the answer?
Add Answer to:
use C++ programming language and follow the instruction carefully. thanks! Inputs: . [integer] values (10 times)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In C++ 1. Write a program that allows a user to enter 10 integer values from...

    In C++ 1. Write a program that allows a user to enter 10 integer values from the keyboard. The values should be stored in an array. 2. The program should then ask the user for a number to search for in the array: The program should use a binary search to determine if the number exists in a list of values that are stored in an array (from Step #1). If the user enters a number that is in the...

  • Assignment 6, Merge Arrays (java) Instructions In this assignment, you will write a program which merges...

    Assignment 6, Merge Arrays (java) Instructions In this assignment, you will write a program which merges two arrays of positive integers and removes any duplicate entries. Your program will first ask for a valid length which must be an integer which is 10 or greater. The program should continue to ask until a valid length is entered. The program will then create two arrays of the length entered, fill these with random integers between 1 and 100 inclusive, and print...

  • JAVA: (15 marks) Write a program that creates an integer array with 50 random values, prompts...

    JAVA: (15 marks) Write a program that creates an integer array with 50 random values, prompts the user to enter the index of an element in the array between 0 and 49, then displays the corresponding element value. If the specified index is out of bounds, display an error message (e.g. "Out of Bounds") and ask the user to enter another index. Use a while loop that will keep prompting the user until a valid input is received. To handle...

  • 2. Write a C++ program, that generates a set of random integers and places them in...

    2. Write a C++ program, that generates a set of random integers and places them in an array. The number of values generated and their range are entered by the user. The program then continually prompts the user for one of the following character commands: a: display all the values I: display the values less than a given value g display the values greater than a given value e: display all odd values o: display all even values q: quit...

  • Create a modular program using structured programming to store the amount of money a local store...

    Create a modular program using structured programming to store the amount of money a local store made in sales for each day of the past week. The user will be given the option to enter an amount for the next day, compute the average, find the highest amount, find the lowest amount, or print all the information including the daily sales with the average, highest, and lowest amount. When the user chooses an option to enter an amount for the...

  • I need to Write a test program that prompts the user to enter 10 double values...

    I need to Write a test program that prompts the user to enter 10 double values into an array, calls a method to calculate the average of the numbers, and displays the average. Next, write a method that returns the lowest value in the array and display the lowest number. The program should then prompt the user to enter 10 integer values into an array, calculates the average, and displays the average. The program should have two overloaded methods to...

  • C Programming: Write a program that inputs two strings that represent floating-point values, convert the strings...

    C Programming: Write a program that inputs two strings that represent floating-point values, convert the strings to double values. Calculate the sum,difference,and product of these values and print them. int main(){    // character string value array for user    char stringValue[10];       double sum=0.0;// initialize sum to store the results from 2 double values       double difference=0.0; // initialize difference to store the results from 2 double values       double product = 0.0; // intitialzie product...

  • Written in Java Your job is to produce a program that sorts a list of numbers...

    Written in Java Your job is to produce a program that sorts a list of numbers in ascending order. Your program will need to read-in, from a file, a list of integers – at which point you should allow the user an option to choose to sort the numbers in ascending order via one of the three Sorting algorithms that we have explored. Your program should use the concept of Polymorphism to provide this sorting feature. As output, you will...

  • c# Write compile and test a program named IntegerStatistics. The programs Main() method will: 1. Declare...

    c# Write compile and test a program named IntegerStatistics. The programs Main() method will: 1. Declare an array of 10 integers. 2. Call a method to interactively fill the array with any number of values (up to 10) until a sentinel value is entered. [If an entry is not an integer, continue prompting the user until an integer is entered.] When fewer than 10 integers are placed into the array, your statistics will be off unless you resize the array...

  • C++ Programming Help Please! NOTE: Please READ All Steps very carefully. DO #10! (10 is based...

    C++ Programming Help Please! NOTE: Please READ All Steps very carefully. DO #10! (10 is based off of 9). Program Info:   #9. Write a program that reads in ten whole numbers and that outputs the sum of all the numbers greater than zero, the sum of all the numbers less than zero (which will be a negative number or zero), and the sum of all the numbers, whether positive, negative, or zero. The user enters the ten numbers just once...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT