hi,, the program i made is soppost to reads 3 integers from user and solve the average, the maximum, the minimum and their median value..the problem with the program is that the median section is not working, can u please have a look at it..
#include<stdio.h>
main( )
{
int item[100];
float a, b, c;
int median_index;
float median;
int count;
float sum;
printf("Enter your first integer\n");
scanf(" %f", & a);
printf("Enter your second integer\n");
scanf(" %f", & b);
printf("Enter your third integer\n");
scanf(" %f", & c);
sum = (a + b + c)/3;
for(a=0; a<count; a++){
scanf("%f", &item[a]);
}
for(a=1; a<count; a++)
for(b=count-1; b>=a; --b){
if(item[b-1] > item[b]){
c=item[b-1];
item[b-1] = item[b];
item[b]=c;
}
}
median = count/2;
if(count%2 ==1){
printf("There are odd sets of numbers.\n");
median = item[count/2];
}
else{
median_index = count/2;
printf("There are even sets of numbers.\n");
median = (item[median_index]+item[median_index-1])/2.0;
}
for(c=0; c<count; c++){
printf("%f\n", item[c]);
}
printf("\nThe average is %0.2f\n", sum);
printf("The median is %0.2f\n", median);
if ((a > b) && (a > c))
printf("The maximum %0.2f\n", a);
else if ((b> a) && (b> c))
printf("The maximum is %0.2f\n", b);
else printf("The maximum is %0.2f\n", c);
if ((a < b) && (a < c)) printf("The minimum is %0.2f", a);
else if ((b < a) && (b < c))
printf("The minimum is %0.2f", b);
else printf("The minimum is %0.2f", c);
return 0;
}
<< moderator edit: added [code][/code] tags >>
But now, I can't run the program because there are some errors, all saying:
1.C:42: invalid types `int[100][float]' for array subscript
1.C:46: invalid types `int[100][float]' for array subscript
1.C:47: invalid types `int[100][float]' for array subscript
1.C:48: invalid types `int[100][float]' for array subscript
1.C:49: invalid types `int[100][float]' for array subscript
1.C:66: invalid types `int[100][float]' for array subscript
What did I do wrong? Could anybody help me please?
Thank You.