Make this code better

i have an error on line38 display(rec)

i was trying to a code of bmi but i always get this one error, pls help to fix it

#include <stdio.h> #include <stdlib.h> void bmi(float weight, float height); void display(struct patient rec); struct patient{ int id; char name[30]; int age; float weight, height,ret; }; int main() { struct patient rec[4]; for(int i=0; i<5; i++) { printf("Enter patient's ID: "); scanf("%d", &rec[i].id); printf("Enter patient's name: "); scanf("%s", &rec[i].name); printf("Enter patient's age: "); scanf("%d", &rec[i].age); printf("Enter patient's weight (kg): "); scanf("%.1f", &rec[i].weight); printf("Enter patient's height (m): "); scanf("%.2f", &rec[i].height); //bmi - weight height } display(rec[]); system("pause"); return 0; } void calcbmi(float w, float h) { float bmi; bmi = w / (h * h); return bmi; } void display(struct patient rect[]) { for(int j=0; j<5; j++) { rec[j].ret=calcbmi(rec[j].weight,rect[j].height); printf("%s %d", "Patient's ID",rect[j].id); printf("%s %s", "\nPatient's Name",rect[j].name); printf("%s %d", "\nPatient's Age",rect[j].id); printf("%s %.1f", "\nPatient's Weight",rect[j].weight); printf("%s %.2f", "\nPatient's Height",rect[j].height); printf("%s %.2f", "\nPatient's BMI",rect[j].ret); } }

Reactions 0 reactions

No reactions yet, be the first: comment or tweak the code

Comment on this code:

Please Login or Register to leave a comment.