From the course: C Standard Library
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Rounding and truncating example - C Tutorial
From the course: C Standard Library
Rounding and truncating example
- In this example I want to do something a little different. So, I will not be typing in so much code, but rather I will fill in some very particular parts of the code that require the functions that we just saw. So if you take a look at line five, you will see that we have two double variables, hours and age, because I am using the same example of hours in a parking lot and the age of a person. Hours is 3.1 and age is 14.8. So let's take a look at line seven. It says I parked for this many hours, so I got this many hours charged. So, we are using the hours variable and we have to use some function that will approximate that value to what the parking lot will charge. Remember, this parking lot charges per hour, so if I exceed one hour by one second, I will get charged for the whole hour. So, in this part, the last argument of this printer function call will have to be the ceiling of hours. So, I will type in ceil of hours. Why? Because the ceiling is the next integer not less than the…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
Mathematical functions2m 50s
-
(Locked)
Rounding and truncating51s
-
(Locked)
Rounding and truncating example5m 4s
-
(Locked)
Trigonometric functions1m 42s
-
(Locked)
Trigonometric functions example1m 27s
-
(Locked)
Powers and exponentials1m 9s
-
(Locked)
Powers and exponentials example3m 4s
-
(Locked)
Challenge: Polar coordinate conversion2m 19s
-
(Locked)
Solution: Polar coordinate conversion6m 53s
-
(Locked)
C23 update3m 39s
-
-