#include<stdio.h>
main()
{
int i,year,sum=0;
int old=0,golden=0,adult=0,scence=0,young=0;
for(i=1;i<=20;i++)
{
printf("Input Year Old %d:",i);
scanf("%d",&year);
sum=sum+year;
if(year <15)
{
young=young+1;
}else if(year <20)
{
scence=scence+1;
}else if(year <40)
{
adult=adult+1;
}else if(year <=60)
{
golden=golden+1;
}else
{
old=old+1;
}
}
printf("Young = %d\n",young);
printf("Scence = %d\n",scence);
printf("Adult = %d\n",adult);
printf("Golden = %d\n",golden);
printf("Old = %d\n",old);
sum=sum/20;
if(year <15)
{
printf("Class young!");
}else if(year <20)
{
printf("Scence!");
}else if(year <40)
{
printf("Class adult!");
}else if(year <=60)
{
printf("Class golden!");
}else
{
printf("Class old!");
}
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.