fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. int main(int argc, char *argv[])
  5. {
  6. if (argc != 3) {
  7. printf("Usage: %s height weight\n", argv[0]);
  8.  
  9. }
  10. else {
  11. double height, weight, bmi;
  12.  
  13. height = atof(argv[1]);
  14. weight = atof(argv[2]);
  15.  
  16. bmi = weight / (height * height);
  17.  
  18. printf("height = %f, weight = %f, bmi = %f,", height, weight, bmi);
  19.  
  20. if (bmi<18)
  21. printf("category = underweight");
  22.  
  23. else if(bmi>=18 && bmi<25)
  24. printf(" category = normal weight");
  25.  
  26. else if(bmi>=25 && bmi<30)
  27. printf(" category = overweight");
  28.  
  29. else
  30. printf(" category = obese");
  31. }
  32. return 0;
  33.  
  34. }
Success #stdin #stdout 0s 5380KB
stdin
Standard input is empty
stdout
Usage: ./prog height weight