0% found this document useful (0 votes)
13 views1 page

Quiz Oct 04 2024

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views1 page

Quiz Oct 04 2024

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Question 2:

#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;
}

You might also like