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
2.Write a program which inputs a date in the format dd/mm/yy and outputs it in the
format month dd, year.
For example, 25/12/61 becomes: December 25, 1961
3.Write a program which produces a simple multiplication table of the following format for integers in the range 1 to 9:
1 x 1 = 1
1 x 2 = 2
9 x 9 = 81
4.Write a program which inputs an integer value, checks that it is positive, and outputs its factorial, using the formulas:
factorial(0) = 1
factorial(n) = n × factorial(n-1)
5. Write a program that display numbers from 0 to 10 using three loops.
#include <iostream>
using namespace std;
int main()
{
int height, weight;
cout << "Enter height in centimeters: ";
cin >> height;
cout << "Enter weight in kilograms: ";
cin >> weight;
cout << endl;
if (weight < height / 2.5)
cout << "UNDERWEIGHT";
else if (height / 2.3 < weight)
cout << "OVERWEIGHT";
else
cout << "NORMAL";
cout << endl;
}
Comments
Leave a comment