Question

In: Computer Science

Write a program in C++ to read 10 numbers from keyboard and find their sum, average,...

Write a program in C++ to read 10 numbers from keyboard and find their sum, average, maximum and minimum

Solutions

Expert Solution

ScreenShot:-

Code:-

#include <iostream>

using namespace std;

int main()
{
int n[10]; // declaring array of size 10 to store 10 values.
int sum=0,avg, max,min;
  
int i;
  
for(i=0;i<10;i++)
{
cout << "Enter the "<<i + 1<<" number : "<< endl;
cin>>n[i];
}
  
  
//finding sum of all elements
  
for(i=0;i<10;i++){
sum=sum+n[i];
  
}
  
cout<<"The sum of all elements is : "<<sum<<endl;
  
//finding the average of all elements
avg=sum/10;
cout<<"The average of elements is : "<<avg<<endl;
  
//finding minimum and maximum element
  
// Assuming the first element is maximum and minimum
  
max=n[0];
min=n[0];
for(i=1;i<10;i++)
{
if(max<n[i])
max=n[i];
  
if(min>n[i])
max=n[i];
  
}
  
cout<<"The maximum number is : "<<max<<endl;
cout<<"The minimum number is : "<<min<<endl;
  
return 0;
}


Related Solutions

Write a C++ program to read N numbers. Find sum, product, and average of N numbers
Write a C++ program to read N numbers. Find sum, product, and average of N numbers
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...
Write a C++ program to read in a list of 10 integers from the keyboard. Place...
Write a C++ program to read in a list of 10 integers from the keyboard. Place the even numbers into an array called even, the odd numbers into an array called odd, and the negative numbers into an array called negative. Keep track of the number of values read into each array. Print all three arrays after all the numbers have been read. Print only the valid elements (elements that have been assigned a value). a. Use main( ) as...
Write a C++ program to read characters from the keyboard until a '#' character is read....
Write a C++ program to read characters from the keyboard until a '#' character is read. Then the program will find and print the number of uppercase letters read from the keyboard.
Write a program in java which store 10 numbers and find the sum of odd and...
Write a program in java which store 10 numbers and find the sum of odd and even numbers. Create a program that uses a two dimensional array that can store integer values inside. (Just create an array with your own defined rows and columns). Make a method called Square, which gets each of the value inside the array and squares it. Make another method called ShowNumbers which shows the squared numbers. Write a program in java which has an array...
Write a program in java which store 10 numbers and find the sum of odd and...
Write a program in java which store 10 numbers and find the sum of odd and even numbers. Create a program that uses a two dimensional array that can store integer values inside. (Just create an array with your own defined rows and columns). Make a method called Square, which gets each of the value inside the array and squares it. Make another method called ShowNumbers which shows the squared numbers.
Write a C program that allows: Three integer values to be entered (read) from the keyboard,...
Write a C program that allows: Three integer values to be entered (read) from the keyboard, Display the sum of the three values on the computer screen as follows: The integers that you have entered are: a b c The sum of a , b & c is ______ Thank you! C Code: Output screen:
write a c++ program that prompts a user to enter 10 numbers. this program should read...
write a c++ program that prompts a user to enter 10 numbers. this program should read the numbers into an array and find the smallest number in the list, the largest numbers in the list the sum of the two numbers and the average of the 10 numbers PS use file I/o and input error checking methods
Write a C program to show sum of 10 elements of array and show the average....
Write a C program to show sum of 10 elements of array and show the average. [10]
Part 1: Write a program that finds the sum and average of a series of numbers...
Part 1: Write a program that finds the sum and average of a series of numbers entered by the user. The program will first ask the user how many numbers there are. It then prompts the user for each of the numbers in turn and prints out the sum, average, the list of number from the user. Note: the average should always be a float, even if the user inputs are all ints. Part 2: Same as part 1 except...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT