Question

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++

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:
Write a program that lets the user enter at least 10 values into an array. The...
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++ 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.

  • 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

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

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

  • Rainfall Statistics Write a program that lets the user enter the total rainfall for each of...

    Rainfall Statistics Write a program that lets the user enter the total rainfall for each of 12 months (starting with January) into an array of doubles. The program should calculate and display (in this order): the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest amounts. Months should be expressed as English names for months in the Gregorian calendar, i.e.: January, February, March, April, May, June, July, August, September, October, November, December....

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

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

  • Write a C program Design a program that uses an array to store 10 randomly generated...

    Write a C program Design a program that uses an array to store 10 randomly generated integer numbers in the range from 1 to 50. The program should first generate random numbers and save these numbers into the array. It will then provide the following menu options to the user: Display 10 random numbers stored in the array Compute and display the largest number in the array Compute and display the average value of all numbers Exit The options 2...

  • Design a program that lets the user enter the total rainfall for each of 12 months...

    Design a program that lets the user enter the total rainfall for each of 12 months into an array. The program should calculate and display the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest amount. PLEASE MODULARIZED THE CODE   PLEASE USE C PROGRAMMING AND ADD PSEUDOCODE

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