fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. struct Body{
  5. int id;
  6. double h;
  7. double w;
  8. double bmi;
  9. };
  10.  
  11.  
  12. int main(void) {
  13. struct Body data[]={{1,170,60},{2,150,50},{3,160,56},{4,180,70}};
  14. for(int i=0;i<4;i++){
  15. data[i].bmi=data[i].w/((data[i].h/100)*(data[i].h/100));
  16. printf("%.1f\n",data[i].bmi);
  17. }
  18. // your code goes here
  19. return 0;
  20. }
  21.  
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
20.8
22.2
21.9
21.6