Website by Joshua Bleier

Module 3 - File & Examples

Take a look at some of the other examples to see more sophisticated programs:

  • attack.c has the user attempt to shoot a target by inputting a firing angle and missile speed, then employs the appropriate quadratic to determine where the user's shot falls; it relays this information to the user and allows for refinement of angle and speed values until the user scores a hit on the target, or the user disengages.
    • Note, as in game.c, the use of system function to perform a UNIX command,
    • In this case the sleep function, which puts the process (Not the computer) to sleep for the indicated number of seconds.
  • miscel2.c simply outputs the results of drand48, a function of the math.h library that provides an random double precision real number.
  • newton.c empoloys the concept of user-defined functions and a do loop to find y values for x via the ??? equation, and
  • secant.c loops over two intial user-input guesses to zero in on ??? using the ??? function.

Now spend some time thinking about what we've learned in this module:

  • more sophisticated uses of loops
  • greater employment of user-defined functions to provide clarity in programming, and clean up program code.
  • The use of files to access and operate on stored data.

Continue to the Extend Section ->