ok here is the program i need to write...Write a program that takes in 50 values and prints out the highest, the lowest, the average and
then all 50 input values, one per line. ok i will post what i have so far but i'm stuck. i just need a little nudge as i would like to solve this my self, i started with the top down method and decide to write the loop for putting the values but when i go to try and get it to add all the values and average it thats where i'm having problems. also i used 5 instead of 100 as it would be easier to manage for debugging, and i didn't get around to the sort function yet as i am trying to solve the first part i attached the code your help is greatly apprieciated.
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
int arrayValues[5];
int sum = 0;
int total = 0;
int average = 0;
for (int i = 0; i < 5; i++)
{
cout << "Please enter the values: ";
cin >> arrayValues[i];
}//end of arrayValues for loop
cout << "The sum is: " << total + sum << endl;
}//end of main
okay first of all u need to add total with your array's value inside that loop
1 2 3 4 5 6 7 8
for (int i = 0; i < 5; i++)
{
cout << "Please enter the values: ";
cin >> arrayValues[i];
total += arrayValues[i]; //this will add your array's value to total;
}//end of arrayValues for loop
i dont think u need
cout << "The sum is: " << total+sum<<endl;
instead just do :
cout<< "The sum is: " <<total<<endl;
and for average, u should use double/float , (except u want to get the average in lower precision)
so u get the total, and u know the number of values in the array