Write a programs to read the age of 100 persons and count the number of persons in the age group 50 to 60. Use for and continue statements.
#include <stdio.h>
void main()
{
int n=0,age,count=0;
clrscr();
printf("Enter the age of persons to goto end type 999:");
for(;n<=100;n++)
{
scanf("%d",&age);
if(age==999)
break;
if(age>50&&age<60)
{
count=count+1;
continue;
}
}
printf("Age above 50 and below 60: %d",count);
getch();
}
#include <stdio.h>
void main()
{
int n=0,age,count=0;
clrscr();
printf("Enter the age of persons to goto end type 999:");
for(;n<=100;n++)
{
scanf("%d",&age);
if(age==999)
break;
if(age>50&&age<60)
{
count=count+1;
continue;
}
}
printf("Age above 50 and below 60: %d",count);
getch();
}
No comments:
Post a Comment