fork download
  1. #include <stdio.h>
  2.  
  3. struct body{
  4. double id;
  5. double height;
  6. double weight;
  7. double bmi;
  8. };
  9. int main(void) {
  10.  
  11. struct body data[]={
  12. {1,170,60},
  13. {2,150,50},
  14. {3,160,56},
  15. {4,180,70},
  16. };
  17. for(int i=0;i<4;i++){
  18. printf("id:%lf\n",data[i].id);
  19. printf("height:%lf\n",data[i].height);
  20. printf("weight:%lf\n",data[i].weight);
  21. printf("bmi:%lf\n",data[i].weight/((data[i].height/100)*(data[i].height/100)));
  22. }
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
id:1.000000
height:170.000000
weight:60.000000
bmi:20.761246
id:2.000000
height:150.000000
weight:50.000000
bmi:22.222222
id:3.000000
height:160.000000
weight:56.000000
bmi:21.875000
id:4.000000
height:180.000000
weight:70.000000
bmi:21.604938