passing struct to the function

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
  #include<iostream>
#include<fstream>

using namespace 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;
		}
		
		else return 0;
		//cout<<"you should modifiy your weight";

		
		
		
		
	}
What you passed is the name of the struct. Function parameters need a data type. Struct is the data type, not person.
Last edited on
so what should I change here to make that fix?could you exactly say where and what to change?
Topic archived. No new replies allowed.