1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
#include<stdio.h>
main()
{
int age, b, c, d, e, f;
clrscr();
b=0;
c=0;
d=0;
e=0;
f=0;
do
{
if(getch()=='l')
printf("There are:\n%d Infants\n%d Young aged\n%d Middle aged\n%d Old aged\n%d Really old aged\n", b, c, d, e, f);
else
{
printf("Please enter an age: ");
scanf("%d", &age);
if(age>=0 && age <=18)
{
b=b+1;
printf("1 Infant added.\n<ENTER> to input another age, 'l' for a list\n of ages or 'q' to quit.\n");
}
else
if(age>=19 && age<=29)
{
c=c+1;
printf("1 Young aged added.\n<ENTER> to input another age, 'l' for a list\n of ages or 'q' to quit.\n");
}
else
if(age>=30 && age<=50)
{
d=d+1;
printf("1 Middle aged added.\n<ENTER> to input another age, 'l' for a list\n of ages or 'q' to quit.\n");
}
else
if(age>=51 && age<=69)
{
e=e+1;
printf("1 Old aged added.\n<ENTER> to input another age, 'l' for a list\n of ages or 'q' to quit.\n");
}
else
if(age>=70)
{
f=f+1;
printf("1 Really Old aged added.\n<ENTER> to input another age, 'l' for a list\n of ages or 'q' to quit.\n");
}
}
}
while(getch() != 'q');
}
|