Join Eduardo Corpeño for an in-depth discussion in this video Rounding and truncating example, part of C Standard Library.
- 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 value.…So for 3.1 hours, we will get 4 hours there.…
- Working with header files
- C constants and types
- Unformatted and formatted input/output
- Accessing files with C functions
- Generating random numbers
- Converting strings
- Sorting and searching for data
- Manipulating strings
- Using mathematical functions
Skill Level Intermediate
1. The C Standard Library
2. Input and Output Library: stdio.h
3. General Purpose: stdlib.h
4. String Functions: string.h
5. Mathematical Functions: math.h
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.