Question

In C++ Write a program that lets the user enter at least 10 values into an...

In C++

Write a program that lets the user enter at least 10 values into an array. The program then display the largest and smallest values stored in the array.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
#include <iostream>

using namespace std;

int main() {
    int arr[10];
    cout << "Enter 10 numbers: ";
    for (int i = 0; i < 10; ++i) {
        cin >> arr[i];
    }
    int min = arr[0], max = arr[0];
    for (int i = 0; i < 10; ++i) {
        if (arr[i] > max) max = arr[i];
        if (arr[i] < min) min = arr[i];
    }
    cout << "Minimum number is " << min << endl;
    cout << "Maximum number is " << max << endl;
    return 0;
}
Add a comment
Know the answer?
Add Answer to:
In C++ Write a program that lets the user enter at least 10 values into an...
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
  • Write a program that lets the user enter at least 10 values into an array. The...

    Write a program that lets the user enter at least 10 values into an array. The program should then display the largest and smallest values stored in the array. Do it in C++

  • 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...

  • 2) Largest and Smallest Design a program with a loop that lets the user enter a...

    2) Largest and Smallest Design a program with a loop that lets the user enter a series of numbers. The user should enter-99-99 to signal the end of the series. After all the numbers have been entered, the program should display the largest and smallest numbers entered. a) Use a Do-Until Loop

  • Write a program in C++ that lets the user enter the total rainfall for each of...

    Write a program in C++ that lets the user enter the total rainfall for each of 12 months into an array of doubles. The program should calculate and display the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest amounts. Input validation: Do not accept negative numbers for monthly rainfall figures.

  • 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...

  • Write a console-based program ( C # ) that asks a user to enter a number...

    Write a console-based program ( C # ) that asks a user to enter a number between 1 and 10. Check if the number is between the range and if not ask the user to enter again or quit. Store the values entered in an array. Write two methods. Method1 called displayByVal should have a parameter defined where you pass the value of an array element into the method and display it. Method2 called displayByRef should have a parameter defined...

  • Write a C++ program to allow an user to enter username and password, and then compare...

    Write a C++ program to allow an user to enter username and password, and then compare the entered values with the values which stored in a file called login.txt. Display an message "Login successful" if the values are matched, otherwise display "Login fail!. This program allow the user to have three times of tries, if exceeded the number of times, display a message "Number of times is exceeded, please contact administrator (Assume, the stored username is "INTI-IU and password is...

  • For this lab, write a program that lets the user enter a state and the program...

    For this lab, write a program that lets the user enter a state and the program returns that state's capital, stored in a dictionary Requirements: Start by hard coding in all of the states and their capitals the user should be able to enter the name of a state or ask for all states to be printed (one key/value pair per line) If the state is in the dictionary, print its state capital in the form: "The capital of Vermont...

  • In Python 3, Write a program that reads a set of floating-point values. Ask the user...

    In Python 3, Write a program that reads a set of floating-point values. Ask the user to enter the values, then print: The number of values entered. The smallest of the values The largest of the values. The average of the values. The range, that is the difference between the smallest and largest values. If no values were entered, the program should display “No values were entered” The program execution should look like (note: the bold values are sample user...

  • I need to write a program in C that covers this: I need in c language...

    I need to write a program in C that covers this: I need in c language Design a program with a loop that lets the user enter a series of numbers the user should enter -99 to signal the end of the series. after all the numbers have been entered, the program should display the largest and smallest numbers entered.

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