Hey, this program suppose to calculate B.M.I and says if you are fit or not.But it only returns one answer I don't know exactly which part is the problem.But I think that there is some problem with the calculating formula when it uses the struct information.I cant see where is the problem could you please see which part cause this problem.
#include<iostream>
#include<fstream>
usingnamespace std;
struct person{
int weight;
int height;
char name[50];
};
int funchealth(person); //function decleration
int main(){
int a;
person p;
cout << "Enter Full name: ";
cin.get(p.name, 50);
cout << "Enter your weight: ";
cin >> p.weight;
cout << "Enter your height: ";
cin >> p.height;
ofstream file;
file.open("info.txt");
a=funchealth(p);
if(a==1){
cout<<p.name<<" you are fit"<<endl;
file<<p.name<<" you are fit"<<endl;
file<<"keep your good diet!"<<endl;
}
else{
cout<<p.name<<" you are not fit"<<endl;
file<<p.name<<" you are not fit"<<endl;
file<<p.name<<"you need to have balance your calorie intake and calorie burn.";
}
}
int funchealth(person p1){
double z;
double c=(p1.height)*(p1.height);
z=p1.weight/c;
if(z>18&&z<25){
// cout<<"you are fit";
return 1;
}
elsereturn 0;
//cout<<"you should modifiy your weight";
}