In have been coding a small program to calculate the % body fat. But is giving the error C2064 as above. Any help will be appreciated guys!

The error is here;

/Compute Body fat percentage for male

if (gender == "Male"){
   BFat = 495/(1.0324-.19077(log(abdomen-neck))+.15456(log(height)))-450; // THE ERROR IS HERE
}

else if (gender == "Female"){
	BFat = 495/(1.29579-.35004(log(abdomen+hip-neck))+.22100(log(height)))-450; // THE ERROR IS HEAR
}

cout << "The body fat percentage content is : " << BFat;

return 0;

}

Edited 6 Years Ago by Nick Evan: Added code-tags

Comments
Resurrecting a 4 year old thread is not done on this forum.

Thanks Nick. I am using VC++ and when I tried to put #include <c.math>, I was told it doesnt recognize that. I have already used the header, #include <math.h> but it is not working. I have tried to figure out what is wrong, but I can't get it. Any further suggestions will be appreciated as I need to complete this program urgently. Actually it is a straight forward code; and now let me post the full code here:

// This program calculates the body fat percentage based on the US Navy formula
//This  formula is different for men and women and is as follows
// For Men the formula is: %Fat=495/(1.0324-.19077(log(abdomen-neck))+.15456(log(height)))-450 
// The locations for men: 
//Abdomen: Horizontal at the level of the navel. This is not the minimal width.
//Neck: Inferior to the larynx with the tape sloping slightly downward to the front.
//Height: Is measured without shoes.
// For Women the formula is: %Fat=495/(1.29579-.35004(log(abdomen+hip-neck))+.22100(log(height)))-450 
// The locations for women:
//Abdomen: Horizontal, at the level of minimal abdominal width. 
//Hip: Largest horizontal circumference around the hips. 
//Neck: Inferior to the larynx with the tape sloping slightly downward to the front. 
//Height: Is measured without shoes.

// It is important to note that all measurements are in cm

#include <iostream> // i/o function
#include <string>
#include <math.h>

using namespace std; 

int main()
{

// Variable declarations

	double abdomen;
	double hip;
	double neck;
	double height;
	double BFat;
	string gender; // Either Male of Female
		
// Enter the client's details

//Enter Abdomen size
cout << "Please enter the abdomen meassurements in cm: " << endl;
cin >> abdomen;

// Enter hip size
cout << "Please enter the hip meassurements in cm: " << endl;
cin >> hip;

// Enter neck size
cout << "Please enter the neck meassurements in cm: " << endl;
cin >> neck;

// Enter height
cout << "Please enter the height meassurements in cm: " << endl;
cin >> height;

// Gender identification
cout << "Please enter your gender, either Male or Female: " << endl;
cin >> gender;

//Compute Body fat percentage for male

if (gender == "Male"){
   BFat = 495/(1.0324-.19077(log(abdomen-neck))+.15456(log(height)))-450; // THE ERROR IS HERE
}

else if (gender == "Female"){
	BFat = 495/(1.29579-.35004(log(abdomen+hip-neck))+.22100(log(height)))-450; // THE ERROR IS HEAR
}

cout << "The body fat percentage content is : " << BFat;

return 0;

}

Edited 6 Years Ago by Nick Evan: Added code-tags (again...)

Use * to indicate multiplication.

if (gender == "Male"){
BFat = 495/(1.0324-.19077[B]*[/B](log(abdomen-neck))+.15456[B]*[/B](log(height)))-450; // THE ERROR IS HERE
}

else if (gender == "Female"){
BFat = 495/(1.29579-.35004[B]*[/B](log(abdomen+hip-neck))+.22100[B]*[/B](log(height)))-450; // THE ERROR IS HEAR
}

Edited 6 Years Ago by Dave Sinkula: Colors and bold -- I am still the optomist, no?

Comments
OMG, how on earth did I miss this?? :(

Thanks Dave. Yes, it worked. I had removed most of the brackets and used the * for multiplication and it had worked and when I came here to post the reply, I found out that you had indeed correceted excattly that way. Thanks Dave. But when I just use the log, it doesnt give the correct value. In order for me to get the correct answer, I have to use log10. It works perfectly now with those corrections.

I am figuring out how to use the results now to make an informed decision in the medical field. I just wanted it to do the basics and post the results first, which it has done, and I think the rest is now pretty easy, intepretation of the results (just using the if, else conditions). The next thing would be to have the GUI. I have seen on the web this calculator thing, doing exactly what I have done above, with even less precision, selling for $20. That is why I sat down and decided to write this small and staright forward program. Amazing!

Use * to indicate multiplication.

if (gender == "Male"){
BFat = 495/(1.0324-.19077[B]*[/B](log(abdomen-neck))+.15456[B]*[/B](log(height)))-450; // THE ERROR IS HERE
}

else if (gender == "Female"){
BFat = 495/(1.29579-.35004[B]*[/B](log(abdomen+hip-neck))+.22100[B]*[/B](log(height)))-450; // THE ERROR IS HEAR
}

Edited 6 Years Ago by Luks: n/a

This question has already been answered. Start a new discussion instead.