Description
Before doing this assignment, you should already know the following things:
Define and use variables in C++
Simple operator in C++ (+, -, *, /, %)
How the computer stores signed integers Define, initialize and use struct
Review Questions
(You should write the answers to the following questions in the same file)
1. Please write down the upper and lower bound of the following types:
For example: uint16_t: 0~65535 uint8_t int8_t int16_t
(Please read this page if you do not know uint8_t and int8_t)
3. Define a structure, which includes year, month, day and time information. Then define a variable of this structure and initialize it.
Programing Exercise
We have provided the skeleton code (exer1_1.cpp and exer1_2.cpp), you only need to complete the calculation part. For compiling and running the code, using the following commend lines:
If you want to know more about compiling with g++, click here
1. Write a program that asks the user to enter the number of seconds as an integer value (use type long) and that then displays the equivalent time in days, hours, minutes, and seconds. The output should look like this: Enter the number of seconds: 31600000 31600000 seconds = 365 days, 17 hours, 46 minutes, 40 seconds
1 / 2
2. Write a program that asks the user to enter the number of hours as an float value (use type float) and that then displays the equivalent time in hours, minutes, and seconds (Ignore the fractional part of second). The output should look like this: Enter the number of hours: 7.244 7.244 hours = 7 hours, 14 minutes, 38 seconds
DO NOT FORGET TO COMMIT AND PUSH YOU CODE
2 / 2
Reviews
There are no reviews yet.