Hi I'm quite new to writing programs in C language. I've been working hard on a program and my output isn't coming out as it should.
Problem is you're supposed to enter 7 numbers. The program should sort the numbers in 5 categories of ages. Then calculate the average. I only get 0's and garbage for the average.
Sorry as this is homework if it offends anyone, but I can't see what's wrong.
could anyone point me in the right direction?
#include<stdio.h>
int main ()
{
int age, min, ret ,cent ,sum, invalid, total ,cptmin=0, cptret=0, cptcent=0,cptinvalid=0
,i=1;
float avg;
for( i=1; i<=7; i++);
printf("Enter the age of 7 people:", age);
scanf("%d)", &age);
i++;
if( age>0 && age<19){
min++;
}
else if (age>55 &&age<120){
ret++;
}
else if (age>=100 && age<120){
cent++;
}
else if(age<1 && age >120){
invalid++;
}
total=min+ret+cent;
avg= totale/i++;
printf("\n Number of under age people :%d", cptmin);
printf("\n Number of retirees :%d", cptret);
printf("\n Number of people over 100 :%d", cptcent);
printf("\n Number of invalid entries :%d" cptinvalide);
printf("\n Average age :%d", avg);
scanf("%.2f",&avg);
getch ();
}
thank you for any ideas