Quiz Oct 04 2024
Quiz Oct 04 2024
#include <iostream>
using namespace std;
int main()
{
int year;
cout << "Enter a year: ";
cin >> year;
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
cout << "Year " << year << " is a leap year." << endl;
else
cout << "Year " << year << " is not a leap year." << endl;
return 0;
}
Question 3:
#include <iostream>
using namespace std;
int main()
{
double height, weight, BMI;
const double poundToKilogram = 0.45359237;
const double inchToMeter = 0.0254;
cout << "Type your height (inch): ";
cin >> height;
cout << "Typre your weight (pound): ";
cin >> weight;
height *= inchToMeter;
weight *= poundToKilogram; //convert to kg and m
BMI = weight / (height * height);
if (BMI < 18.5)
cout << "Underweight";
else if (BMI >= 18.5 && BMI < 25.0)
cout << "Normal";
else if (BMI >= 25.0 && BMI < 30.0)
cout << "Overweight";
else
cout << "Obese";
return 0;
}