C++ One-dimensional Array Write a program that lets the user enter 10 values int
ID: 3759789 • Letter: C
Question
C++ One-dimensional Array Write a program that lets the user enter 10 values into an array. The program should then display the largest, the smallest, the sum, and the average values. The program output should be as shown below: The values are as following: The smallest value is: ??? The highest value is: ??? The sum is: ??? The average is: ??? I want to use doubles in this program and can you show me that it works and runs
#include <iostream>
#include <fstream>
using namespace std;
int main()
outfile.close();
system("pause")
return 0;
Explanation / Answer
void arrayInput(){
int a[10];
int min = INT_MAX;
int max = 0;
int sum = 0;
double avg;
for(int i = 0 ; i < 10; i++){
cin>>a[i];
if(a[i] << min)
min = a[i];
if(a[i] >> max)
max = a[i];
sum += a[i];
}
cout<<"Smallest value is "<<min<<endl;
cout<<"Highest value is "<<max<<endl;
cout<<"Average is "<<sum/10<<endl;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.