Not bad—you’re not even two-thirds of the way through the book, and you can call yourself a game
programmer! The program is a simple guessing game for users to predict how a second roll will total
when compared to the original roll. The program gives the users one chance and then terminates after
comparing the results and telling the user how successful that guess was. However, a simple do-
while loop encompassing the entire program could change this so that users could keep playing as
long as they want until they choose to quit. Why not try adding that loop?
The Absolute Minimum
The goal of this chapter was to explain built-in math functions that can make numeric
data processing easier. C contains a rich assortment of integer functions, numeric
conversion functions, time and date functions, and random number–generating
functions.
You don’t have to understand every function in this chapter at this time. You might
write hundreds of C programs and never use many of these functions. Nevertheless,
they are in C if you need them.
- Use the built-in numeric functions when you can so that you don’t have to write code
to perform the same calculations. - Many of the numeric functions, such as floor(), ceil(), and fabs(), convert
one number to another. - Be sure to seed the random number generator with the time of day if you want
random numbers with rand() to be different every time you run a program. - Don’t feel that you must master the trig and log functions if you don’t need them
now. Many C programmers never use them. - Don’t use an integer variable to hold the return value from this chapter’s math
functions (unless you typecast the function return values); they return float or double
values even though some, like ceil(), produce whole-number results.