need help..

hi..i need some help..my programme cannot run..i dont know ehre the problem..can anyone help me? this is my coding;


#include<iostream>
#include<iomanip>
#include<math.h>

float female (float bmi);
using namespace std;

int main()

{

char gender;
float cmm;


cout <<"Please enter your gender. M or F"<<endl;
cin>>gender;
if (gender == 'F')
female (cmm) ;
else
return 0;



}

float female (float bmi)
{
float weight;
float height;
char response;
do
{
cout << "*****************************\n";
cout << "Please enter your weight (kg): ";
cin >> weight;
cout << "Please enter your height (m): ";
cin >> height;
bmi = weight/(height*height);
cout<<"\n";
cout << fixed << showpoint << setprecision(2);
cout<<"Your BMI is " << bmi << endl;

if (bmi < 18.5)
{
cout << "You are underweight!" << endl;
cout << "Eat more!!" << endl;
}
else if (bmi >= 18.5 && bmi <25)
{
cout << "You are normal!"<<endl;
cout << "You are cool!"<<endl;
}
else if (bmi >= 25 && bmi <30)
{
cout << "You are overweight!"<<endl;
cout << "You should diet!"<<endl;
}
else if (bmi >= 30)
{
cout << "You are obesity!"<<endl;
cout << "You should do more exercise!"<<endl;
}

else
cin.get();

cin.get();
cout << endl;

cout << "Would you like to enter the information again? ";
cin >> response;
}
while (toupper(response) == 'Y');
cout << "Okay, see you next time.." << endl;
return 0;
}
Are you getting errors, or is your program not running?
Not indented, but here is a more eye-friendly version for anyone who wants to fix it.

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
#include<iostream>
#include<iomanip>
#include<math.h>

float female (float bmi);
using namespace std;

int main()

{

char gender;
float cmm;


cout <<"Please enter your gender. M or F"<<endl;
cin>>gender;
if (gender == 'F')
female (cmm) ;
else 
return 0;



}

float female (float bmi)
{
float weight;
float height;
char response;
do 
{
cout << "*****************************\n";
cout << "Please enter your weight (kg): ";
cin >> weight;
cout << "Please enter your height (m): ";
cin >> height;
bmi = weight/(height*height);
cout<<"\n";
cout << fixed << showpoint << setprecision(2);
cout<<"Your BMI is " << bmi << endl;

if (bmi < 18.5)
{ 
cout << "You are underweight!" << endl;
cout << "Eat more!!" << endl;
}
else if (bmi >= 18.5 && bmi <25) 
{
cout << "You are normal!"<<endl;
cout << "You are cool!"<<endl;
}
else if (bmi >= 25 && bmi <30)
{
cout << "You are overweight!"<<endl;
cout << "You should diet!"<<endl;
}
else if (bmi >= 30)
{
cout << "You are obesity!"<<endl;
cout << "You should do more exercise!"<<endl;
}

else 
cin.get();

cin.get();
cout << endl;

cout << "Would you like to enter the information again? ";
cin >> response;
}
while (toupper(response) == 'Y');
cout << "Okay, see you next time.." << endl; 
return 0;
} 
there is error..it succed but tehre is uninitialized local variable 'cmm' used..i don't know how to fix it..thnk u everyone for helping me..
Last edited on
Simple. Initialize cmm. That means make it equal to a integer value, like 1, 15, or 25.
i just do that,but there is function call..if change to the number,the function call for float female...can u just do the new coding for me..:)
why do you even have cmm in main, if your main is not even utilizing it .. just delete
float cmm;
and declare and initialize it in you function where you need to use it.

-TAZO
thnks for help..it done...:)..
Topic archived. No new replies allowed.