PURPOSE:
- Prompt the user to enter 6 integers and stores them as elements of array.
- Display all 6 numbers after all numbers are entered.
- Display the average and the rage of the numbers.
#include <iostream>
#include <string>
#include <array>
using namespace std;
int main()
{
cout << "Enter 6 integer." << endl;
array <int, 6> num = i;
for (int i=0; i < num.size(); i++) {
cin >> i; // prompt user to enter 6 integers.
count = 0;
total = 0;
if (i==i){ // check to see if the numbers enter is equal to each other
cout << "You can not enter the same number." << endl;
cin >> i;
}
else if (i!=i) { // else ! if the n umbers is not equal to each other add
count = count + 1;
float total = 0;
total+= num[i]; // find the sum of all inputs
max = 0;
min = 0;
if (i > max) { // find the max value of the inputs
max = i;
}
if (i < min) { // find the min value of the inputs
min = i;
}
}
}
cout << "Number entered: " << num << endl; // displays all integers that are entered
cout << "Average: " << total/count << endl;
cout << "Range:" << max-min << endl;
cout << "Maximum:" << max << endl;
!
span>cou
t << "<Minimum:" << min << endl;
system("PAUSE");
return(0);
}
i is the numbers... I dont know if that's exactly how you would write this statement. I just learned this the other days now there an assignment on it. Please help.