0% found this document useful (0 votes)
36 views2 pages

C++ Assignment 1

The document is a C++ program that calculates body mass index (BMI) by prompting the user to enter their height, weight, and then displays their BMI along with an assessment of whether they are underweight, normal weight, overweight, or obese. It includes preprocessor directives, namespaces, function declarations, variable declarations and assignments, input/output statements to collect user input and display output, and conditional statements.

Uploaded by

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

C++ Assignment 1

The document is a C++ program that calculates body mass index (BMI) by prompting the user to enter their height, weight, and then displays their BMI along with an assessment of whether they are underweight, normal weight, overweight, or obese. It includes preprocessor directives, namespaces, function declarations, variable declarations and assignments, input/output statements to collect user input and display output, and conditional statements.

Uploaded by

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

#include <iostream>// preprocessor directive

using namespace std;// which name space to use


int main()// beginning of function called "main"
{
int feet; // assigning variables
double inches;
double totalHeight;
double weight;
double bmi;

cout << "BMI Calculator\n\n" //Displays title


"Please enter height\n"; //displays text
cout << "Feet:";
cin >> feet; //user defines variable by typing response
cout << "Inches:";
cin >> inches;
cout << "Please enter weight\n"
"lbs:";
cin >> weight;

totalHeight = (feet * 12) + inches;// add feet and inches


bmi = weight*703 / (totalHeight * totalHeight); // formula for bmi

cout << "your BMI is: ";


cout << bmi << endl; //bmi result
if (bmi < 18.5)
cout << "Your are underweight!"; // bunch of "if" statements depending what
your bmi is
if (bmi > 18.5 && bmi <24.9)
cout << "You are normal weight!";
if (bmi > 25 && bmi<29.9)
cout << "you are overweight!";
if (bmi > 29.9)
cout << "You are obese!";
}
Chapter 1:

29: 45

30: 7

31: 28

32: 365

33: area was defined as width x length before you assigned the values to width and length

Chapter 2:

25 A): 0,100

25 B): 8, 2

25 C):

I am the incredible computing

Machine

And I will

Amaze

You.

26 A)

Be careful!

This might/n be a trick question

26 B: 23, 2

27

- No OC brackets around “iostream”


- No semicolon necessary after int main ()
- No semicolon after int a,b,c or =3,=4,=1+b
- Cout is capitalized, Only one Bracket after cout, I don’t know that the “< C” is trying to do

You might also like