c.ihypress.ca: examples of C programs
Home > 4. Loops
  1. A simple count from 1 to 100
    A program that displays the numbers between 1 and 100.
  2. Mission to the Moon
    This program computes the length of a mission to take photographs around the Moon given the time it takes to get there and to go around the Moon once.
  3. The fuel tank program
    A program that monitors the amount of fuel in a tank and gives a warning if the supply falls below 10% of the tank's capacity.
  4. Simple countdown using a for loop
    A program that displays all the numbers between 60 and 0 and then prints the word LIFTOFF afterwards.
  5. Sums and averages
    A program that counts, sums and calculates the average of all the numbers in a file of integers.
  6. Birdwatching program (fixed loop & file input)
    This program reads a file that contains 12 lines of bird sightings and adds up all the sightings for a year.
  7. Birdwatching program (EOF loop & feof)
    A program similar to the previous one but with an aunkown number of records in the file.
  8. Birdwatching program (EOF loop & status var)
    The same program that works with an unknown number of records but uses a status variable instead of the foef statement.
  9. Birdwatching program (EOF loop, no status var)
    The same program that works with an unknown number of records but does not use a status variable nor an foef statement.
  10. Input validation loop (do-while)
    A program that shows the best use of a do-while loop, an input validation loop. This particular program validates that the color entered is a valid traffic light color.
Ihypress.ca is online since February 17, 2005.
[ | | ]