Calculating the lowest and highest values
What can I inject to make this program calculate the youngest entry and the oldest entry. So far it can calculate average and number of entries.
Code:
#include <stdio.h>
#include <stdlib.h>
#define MAXARR 100
void main (void)
{
int
mode[MAXARR], i, entry;
int counter = 0;
int total = 0;
int total2 = 0;
int mostfreq = 0;
float average, stdev;
printf("Student Age Calculator \n");
printf("======================\n\n");
printf("Input Student's Age:\n");
scanf("%d",&entry);
while (entry >= 0)
{
total = total + entry;
total2 = total2 + entry * entry;
mode[entry]++;
counter = counter +1;
printf("Input the Student's age ; Negative number for Calculations: \n");
scanf("%d",&entry);
}
average = (float)total / (float)counter;
for(i=0;i<100;i++)
{
if (mode[i] > mostfreq);
{
mostfreq = mode[i];
}
}
printf("There were %d ages recorded. \n", counter);
printf("The average age is: %6.2f \n", average);
getchar();
system("PAUSE");
}