Wednesday

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 i,c=0;
    float a[40];
    clrscr();
    printf("\nEnter age of 40 students");
    for(i=0;i<40;i++)
     scanf("%f",&a[i]);
    for(i=0;i<40;i++)
    {
      if (a[i]>15 && a[i]<22)
            c=c+1;
    }
    printf("Total number of students aged between 15 and 21 are %d",c);

     getch();
 }

No comments:

Post a Comment

Rahul-Notes