1 Write a program which inputs a person’s height (in centimetres) and weight (in kilograms) and outputs one of the messages: underweight, normal, or overweight, using the criteria:
Underweight: weight < height/2.5
Normal: height/2.5 <= weight <= height/2.3
Overweight: height/2.3 < weight
#include <iostream>
int main()
{
int weight, height;
std::cout << "Enter weight: ";
std::cin >> weight;
std::cout << "Enter height: ";
std::cin >> height;
if (weight < height / 2.5)
{
std::cout << "Underweight" << std::endl;
}
else if (weight > height / 2.3)
{
std::cout << "Overweight" << std::endl;
}
else
{
std::cout << "Normal" << std::endl;
}
return 0;
}
Comments
Leave a comment