Need C language code for Body Mass Index program.

0 votes
asked by about Turbo C++
edited by

1 Answer

0 votes
No avatar answered by (193k points)

// BMI.cpp : Defines the entry point for the console application.
//BMI Calculator
//Created by Rahul Kucheria
//Oct 29th, 2011

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

using namespace std;

int main()

{
    float weight;
    float 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 (toupper(response) == 'Y');
   cout << "Okay, see you next time.." << endl; 
return 0;
}

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register
...