B
bmlclemson08
I'm trying to figure out why this program is not printing out the
correct mode... suggestions?
int main(){
int qty, num, mode, a_1[count], a_2[MAX], sum = 0;
float mean;
int max_qty = 0;
printf ("Enter how many: ");
scanf ("%i", &qty);
if (qty > MAX)
printf ("Enter less than 50 numbers.\n");
else
for (num = 0; num < qty; num++){
printf ("Enter data %i:", num);
scanf ("%i", &a_2[num]);
sum += a_2[num];
}
for (num = 0; num < count; num++){
if (a_1[num] > max_qty){
max_qty = a_1[num];
mode = num;
}
}
mean = (float)sum / qty;
if (qty <= MAX)
printf ("The mean is %.2f.\n", mean);
printf ("The mode is %i.\n", mode);
return 0;
}
Thanks,
Brandon
correct mode... suggestions?
int main(){
int qty, num, mode, a_1[count], a_2[MAX], sum = 0;
float mean;
int max_qty = 0;
printf ("Enter how many: ");
scanf ("%i", &qty);
if (qty > MAX)
printf ("Enter less than 50 numbers.\n");
else
for (num = 0; num < qty; num++){
printf ("Enter data %i:", num);
scanf ("%i", &a_2[num]);
sum += a_2[num];
}
for (num = 0; num < count; num++){
if (a_1[num] > max_qty){
max_qty = a_1[num];
mode = num;
}
}
mean = (float)sum / qty;
if (qty <= MAX)
printf ("The mean is %.2f.\n", mean);
printf ("The mode is %i.\n", mode);
return 0;
}
Thanks,
Brandon