Introduction to PASS, and Exercises on Operators and Basic I/O
3 Q1a. Download area.cpp file from the course website. There are syntax/logical errors in this area.cpp file, please correct them.
Program reads the width and height of a rectangle. The program computes and output the area of the rectangle. Is the program easy to understand? Why?
5 Q1b. Revise program to print notes for the input and output of the program Test your program using PASS
Q1c: Improve the programming style of the program More meaningful variable name to reflect the purpose of the variable Indentation (use the tab character to indent) Add comments; 6
Q2a: Body Mass Index (BMI) Read the weight and height of a person Calculate and print the Body Mass Index (BMI) Test your program using PASS 7
- Consider the data type needed, int or double? - To print to 2 decimal places, you may use cout<<setprecision(2). - To use setprecision(), you need #include 8
Q2b: Body Mass Index (BMI) in pounds 1 kg = 2.21 pounds Test your program using PASS 9
Q3: Write a program to converts the input value to Minutes and Seconds Read in the number of seconds Converts it to minutes and seconds. Test your program using PASS 10
Q4: Write a program to converts the input value to Hours, Minutes and Seconds Problem in Q3 60 minutes equal to 1 hour. Test your program using PASS 11