Body Mass Index Solver


/ Published in: C
Save to your folder(s)

Body Mass Index Solver


Copy this code and paste it in your HTML
  1. //Icd Dpt
  2. // This program calculates the Body Mass Index of a human body. It has been written in C.
  3. #include<stdlib.h>
  4. #include<stdio.h>
  5. #include<math.h>
  6. #define EXP 2
  7. main(void)
  8. {
  9. float bmi, wei, hei;
  10. system("clear");
  11. printf("*** This program calculates the Body Mass Index of a human body. Height should be entered in meters and weight in kgs *** \n");
  12. printf("\n");
  13. printf("Enter Body Weight \n");
  14. scanf(" \n%f",&wei);
  15. printf("Enter Body Height \n");
  16. scanf("%f",&hei);
  17. if (hei==0) {printf("Height cannot be zero \n"); return 0;}
  18. hei=pow(hei, EXP);
  19. bmi=wei/(hei);
  20. printf("\n\n");
  21. printf("You entered \n");
  22. printf("Height = %.3f \n", hei);
  23. printf("Weight = %.3f \n", wei);
  24. printf("The Body Mass Index = %f \n", bmi);
  25. printf("Press enter to continue... \n");
  26. fflush(stdin);
  27. return 0;
  28. }

URL: bmi

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.