fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. struct Body{
  5. int id;
  6. double height;
  7. double weight;
  8. double bmi;
  9. };
  10.  
  11. int main(void){
  12. struct Body data[]={{1,170,60},{2,150,50},{3,160,56},{4,180,70}};
  13. for(int i=0;i<4;i++){
  14. data[i].bmi=data[i].weight/((data[i].height/100)*(data[i].height/100));
  15. printf("id:%d,BMI:%lf\n",data[i].id,data[i].bmi);
  16. }
  17. return 0;
  18. }
  19.  
Success #stdin #stdout 0s 5288KB
stdin
Standard input is empty
stdout
id:1,BMI:20.761246
id:2,BMI:22.222222
id:3,BMI:21.875000
id:4,BMI:21.604938