Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

LABORATORY ACTIVITY No.

Name: Jac Angelo T. LIM


Year and Section: BSCE 1A

1. Write a program that has 2 variables: weeks and days declared as integer type. Initialize weeks to 18. Then, have your program
calculate the number of days and output a statement giving this information: “There are 126 days in 18 weeks.”

Note: The 1st blank in days is the number of days in 18 weeks. 18 would appear on the 2nd blank. Do not just simply write 18 but you
must have to call or invoke the variable that holds for the number of weeks.

2. Translate the following algorithm into C++ code:

Step 1: Declare a double variable named miles with initial


value 100.
Step 2: Declare a double constant named
KILOMETERS_PER_MILE with value 1.609.
Step 3: Declare a double variable named kilometers,
multiply miles and KILOMETERS_PER_MILE, and
assign the result to kilometers.
Step 4: Display kilometers to the console.

a. Type your C++ code in the C++ IDE and execute your
program.
b. What is the value of the kilometers in step 4? 160.9 km
c. Support your answer by taking a screenshot of the
output of your program.
3. (Convert feet into meters). Write a program that declares and initializes a variable in feet, converts it to meters, and displays the result.
One foot is 0.3048 meter. (You can declare any value for the feet, Example if you declare feet as equal to 15).

Expected Output:
15 feet is 4.572 meters

4. (Find the number of years). Write a program that declares and initializes a value in minutes (example 1 million), and displays the
number of years and days for the minutes. For simplicity, assume a year has 365 days.

Expected Output:

1000000 minutes is approximately 1 year(s) and 329 day(s)


Note:
You must take screenshots of your program and output for the submission of your laboratory activity. Your work must be
submitted via google classroom.

CBE4 – Computer Fundamentals and Programming Unit 3: Variables and Data Types Instructor: J. O. Balolot 1

You might also like