Friday, April 10, 2015

18. Write a C program to read age of 40 students and count the number of students of the age between 15 and 22.

#include<stdio.h>#include<conio.h>
  void main()

int age[40],i,count=0;
clrscr();
printf("\n Input age of 40 students:-");
for(i=0;i<40;i++)
scanf("%d",&age[i]);
for(i=0;i<40;i++)
{
if(age[i]>15&&age[i]<22)
count++;
}
printf("There are %d students whose age is in between 15 and 22 years",count);
getch();
}

No comments:

Post a Comment