Array

I have a problem with my code seems there is an error at some part. Please help me.


#include <iostream>
using namespace std;

int main ()
{

int max, min, size;
double box[100] , count , no;
double average ,sum, total;
no=0;
max=0;
min=0;
total=0;
sum=0;

cout << "How many number do you want to input? ";
cin >>size;

cout << "Input the number 1: ";
cin >> box[no];

sum+= box[no];
min = box[no];
max=box[no];

for (no=1; no<size; no++)
{
cout << "Input the number " << no+1 << " : ";
cin >> box[no] ;

sum += box[no];

if (box[no] > max)
max = box[no];

if (box[no] < min)
min = box[no];
}

average = sum/size;

for (count=0 ; count < size; count++)
{
if (box[count] > average)
total += box[count];
}

cout << endl;
cout << "The average of the numbers is: " << average << endl;
cout << "The largest number among the series is: " << max << endl;
cout << "The smallest number among the series is: " << min << endl;
cout << "The total of numbers greater than average is: " << total << endl;
}

It seems like i have a red squiggle at no and count variable for the box[no] and box[count] i really dont get , is this because of array can only be declare as an integer type ? Someone please help me



Arrays can hold different data types, but the subscript is always going to be an integer. If you're going to use values in no and count as array subscripts, they need to be int, not double.
using_namespace_std;?means...?
Last edited on
Oh thanks man , well explanation ! :D
Topic archived. No new replies allowed.