i need to write a function called bmiCalculator, which calculate based on:
a) the function is to be passed the weight n height as parameters. the weight and height in pounds and feet, respectively.
b) the function should convert pounds to kilograms (0.454kilograms per pound) and feet to meters (0.3046 meters per foot).
c) function should calculate and return bmi value using algebric formula

bmi= weight in kilograms / (height in meters)2

the function prototype is : float bmiCalculator(float lbs,float ft);


Here are what i've done..plz check :

// Test 1/MAR 2006
// A function bmiCalculator is to calculate the body mass index (bmi)

#include <iostream>
#include <iomanip>

using namespace std;

int main()
int pounds;
int feet;
float lbs;
float ft;

cout << " " << endl;
cout << "*** Program to calculate body mass index ***" << endl;
cout << "--------------------------------------------" << endl;
cout << " " << endl;
cout << "Enter your weight in pounds"<< endl;
cin >> pounds;

cout << "Enter your height in feet"<< endl;
cin >> feet;

lbs = (pounds * 0.454);
cout << "Your weight in kilograms is "<< lbs << endl;

ft = (feet * 0.3046);
cout <<"Your height in meter is "<< ft << endl;

float bmiCalculator;

bmiCalculator = (lbs/(ft*ft));
cout << "Your body mass index (bmi) is "<< bmiCalculator << endl;
return 0;

Edited by Dani: Formatting fixed

12 Years
Discussion Span
Last Post by dubeyprateek

hope this can help.

float bmiCalculator(float lbs,float ft) {
      return ((lbs * .454) /(ft * ft * .3046  * .3046 )) ;

Edited by Dani: Formatting fixed

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.