Need C language code for Body Mass Index program.

0 votes
asked by about Turbo C++
edited by

Need C language code for Body Mass Index program.

1 Answer

0 votes
No avatar answered by (193k points)

There are already created programs for BMI. However, if you access Google, you will notice that there are users who posted source code for various applications related to BMI. I recommend accessing Google and then visit the first link. There is a code of a BMI program. Since the author is mentioned in the code, you can use the following one to build or adjust the program's settings:

// 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
...