Statement of C Program: This Program Prints the Average Height of Male and Female :
#include<stdio.h>
#include<conio.h>
void main()
{
int mh[3] , fh[3] , i ; /* mh stands for Male Height and fh stands for Female Height */
float mtot , ftot ; /* mtot stands for Male total height and ftot stands for Female total Height */
float mavg , favg ; /* mavg stands for Males Average Height and favg stands for Females Average Height */
mavg = 0;
favg = 0;
for(i=0 ; i<3 ; i++)
{
printf(" Enter height of male %d :" , i+1);
scanf("%d" , &mh[i] );
mtot = mh[i] + mtot;
}
mavg = mtot/3;
printf("\n");
for(i=0 ; i<3 ; i++)
{
printf(" Enter height of female %d :" , i+1);
scanf("%d" , &fh[i] );
ftot = ftot + fh[i];
}
favg = ftot/3;
printf("\n");
printf(" Average of male height = %f\n" , mavg);
printf(" Average of female height = %f\n" , favg);
getch();
} /* End of main() */
Output:
Enter height of male 1 : 150
Enter height of male 2 : 170
Enter height of male 3 : 190
Enter height of female 1 : 160
Enter height of female 2 : 180
Enter height of female 3 : 200
Average of male height = 170
Average of female height = 180
That's All
0 comments:
Post a Comment