Question

In: Computer Science

In C++, Write a program that accepts exactly ten (10) integer numbers from the user. When...

In C++, Write a program that accepts exactly ten (10) integer numbers from the user. When the user is done inputting these numbers, the program prints back: (i) the sum of the 10 numbers, (ii) the minimum value from the 10 numbers, and (iii) the maximum value from the 10 numbers.

Solutions

Expert Solution

Below is the c++ solution with output screenshot

Code :

// including libraries
#include <iostream>
using namespace std;

// main function
int main()
{
    // declaring an array which will store all 10 numbers
    int num[10];
    cout<<"Enter 10 Numbers :\n";
    // take input 10 numbers
    for(int i=0;i<10;i++)
    {
        cin>>num[i];
    }
    // declare and initialize variables
    int sum = 0;
    int min = num[0];
    int max = num[0];

    // sum all the 10 numbers
    // if the current value is smaller make that minimum
    // if the current value is bigger then make take maximum
    // do this for all the 10 numbers
    for(int i=0;i<10;i++)
    {
        sum += num[i];
        if(num[i]>max){
            max = num[i];
        }
        if(num[i]<min){
            min = num[i];
        }
    }
    // output the result
    cout<<"Sum = "<<sum<<endl;
    cout<<"Minimum = "<<min<<endl;
    cout<<"Maximum = "<<max<<endl;
    return 0;
}

Output :

Note : for better formatting please refer to the code screenshot below


Related Solutions

Question 2. Write a MARIE program that accepts an integer from the user, and if it...
Question 2. Write a MARIE program that accepts an integer from the user, and if it is a prime number the program will output 1, otherwise, the program will output 0. Examples: If the user input is 17, the output would be 1 If the user input is 2, the output would be 1 If the user input is 15, the output would be 0 If the user input is -2, the output would be 0 You should write and...
Write a C++ program that accepts a single integer value entered by user. If the value...
Write a C++ program that accepts a single integer value entered by user. If the value entered is less than one the program prints nothing. If the user enters a positive integer n. The program prints n x n box drawn with * characters. If the user enters 1 , for example the program prints *. If the user enter a 2, it prints ** ** that is , a 2x2 box of * symbols.
Write a C++ program that accepts a positive integer number from the keyboard . The purpose...
Write a C++ program that accepts a positive integer number from the keyboard . The purpose of the program is to find and the display all the square pair numbers between 1 and that number. The user should be able to repeat the process until he/she enters n or N in order to terminate the process and the program. Square numbers are certain pairs of numbers when added together gives a square number and when subtracted also gives a square...
Write a C program that prompt the user to enter 10 numbers andstores the numbers...
Write a C program that prompt the user to enter 10 numbers and stores the numbers in an array. Write a function, smallestIndex, that takes as parameters an int array and its size and return the index of the first occurrence of the smallest element in the array.The main function should print the smallest number and the index of the smallest number.
Write a C++ program that prompt the user to enter 10 numbers andstores the numbers...
Write a C++ program that prompt the user to enter 10 numbers and stores the numbers in an array. Write a function, smallestIndex, that takes as parameters an int array and its size and return the index of the first occurrence of the smallest element in the array.The main function should print the smallest number and the index of the smallest number.
The Sum and The Average In C++, Write a program that reads in 10 integer numbers....
The Sum and The Average In C++, Write a program that reads in 10 integer numbers. Your program should do the following things: Use a Do statement Determine the number positive or negative Count the numbers of positive numbers, and negative Outputs the sum of: all the numbers greater than zero all the numbers less than zero (which will be a negative number or zero) all the numbers Calculate the average of all the numbers. The user enters the ten...
Java Write a program that reads 4 integer numbers from the user combine it into a...
Java Write a program that reads 4 integer numbers from the user combine it into a single number. You need to ask the user to first specify how to combine the numbers (forward or backward). Note that for the backward option you need to check that the last digits should be 0, also for the forward option you need to check that the fist digit is not 0. Use for loops and switch for the menu.                       4. Write an application...
IN C++ PLEASE Requirements Write a program that takes in user input of two integer numbers...
IN C++ PLEASE Requirements Write a program that takes in user input of two integer numbers for height and width and uses a nested for loop to make a rectangle out of asterixes. The creation of the rectangle (i.e. the nested for loop) should occur in a void function that takes in 2 parameters, one for height and one for width. Make sure your couts match the sample output (copy and paste from those couts so you don't make a...
2) Write a C++ program that accepts a sentence as an input from the user. Do...
2) Write a C++ program that accepts a sentence as an input from the user. Do the following with the sentence. Please use C++ style string for this question. 1) Count the number of letters in the input 2) Change all lower case letters of the sentence to the corresponding upper case
Write a C program that uses a loop which prompts a user for an integer 10...
Write a C program that uses a loop which prompts a user for an integer 10 times and stores those integers in an array. The program will print out the numbers entered by the user with a comma and a space separating each number so the numbers can be read easily. The program will then calculate and print out the sum, integer average and floating point average (to 4 decimal points) of the numbers in the array. The information being...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT