Hello i am trying to code a BMI calculator.
This isnt mine i just found on the internet.
The code is
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
|
//BMI Calculator
//Created by Rahul Kucheria
//Oct 29th, 2011
#include<iostream>
#include<iomanip>
#include<math.h>
using namespace std;
int main()
{
unsigned int weight;
unsigned int height;
float bmi;
char response;
do
{
cout<<"*****************************\n";
cout<<"Please enter your weight (lbs): ";
cin>>weight;
cout<<"Please enter your height (inches): ";
cin>>height;
bmi = (weight/ pow(height,2))*703;
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;
else if (bmi >= 25 )
cout<<"You are overweight!"<<endl;
else
cin.get();
cin.get();
cout<<endl;
cout<<"Would you like to enter the information again? ";
cin>>response;
}
while (response == 'Y' || response == 'y' );
return 0;
}
|
I am using Visual c++ 2010 as my compiler.
I am a complete noob and when i try to debug it, i get the following errors
1>------ Build started: Project: as, Configuration: Debug Win32 ------
1> as.cpp
1>c:\users\rahul\desktop\documents\visual studio 2010\projects\as\as\as.cpp(26): error C2668: 'pow' : ambiguous call to overloaded function
1> c:\program files\microsoft visual studio 10.0\vc\include\math.h(583): could be 'long double pow(long double,int)'
1> c:\program files\microsoft visual studio 10.0\vc\include\math.h(535): or 'float pow(float,int)'
1> c:\program files\microsoft visual studio 10.0\vc\include\math.h(497): or 'double pow(double,int)'
1> while trying to match the argument list '(unsigned int, int)'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Can anyone help me out please.
Thanks a lot