fork download
  1. #include <stdio.h>
  2. #include <ctype.h>
  3.  
  4. float bmi_calc(float height, float weight) {
  5. return weight/(height * height);
  6. }
  7.  
  8. int main(void) {
  9. printf("Input your height(m) and weight(kg) in decimals");
  10. float height, weight, bmi;
  11. scanf("%f, %f", &height, %weight);
  12. bmi = bmi_calc(height, weight);
  13. printf(" BMI equals %f", bmi);
  14. if (bmi < 15) {
  15. printf("\nSeverely underweight");
  16. }
  17. else if (bmi < 18.5) {
  18. printf("\nUnderweight ");
  19. }
  20. else if (bmi >= 18.5 && bmi < 24.9); {
  21. printf("\nNormal weight");
  22. }
  23. else if (bmi >= 25 && bmi < 29.9) {
  24. printf("\nOverweight");
  25. }
  26. else if (bmi >= 30) {
  27. prinf("\nObesity");
  28. }
  29. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘main’:
prog.c:11:27: error: expected expression before ‘%’ token
  scanf("%f, %f", &height, %weight);
                           ^
prog.c:20:2: warning: this ‘else’ clause does not guard... [-Wmisleading-indentation]
  else if (bmi >= 18.5 && bmi < 24.9); {
  ^~~~
prog.c:20:39: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘else’
  else if (bmi >= 18.5 && bmi < 24.9); {
                                       ^
prog.c:23:1: error: ‘else’ without a previous ‘if’
 else if (bmi >= 25 && bmi < 29.9) {
 ^~~~
prog.c:27:2: warning: implicit declaration of function ‘prinf’ [-Wimplicit-function-declaration]
  prinf("\nObesity");
  ^~~~~
stdout
Standard output is empty