Programming Assignments - Beginning 2

From Computer Science
Revision as of 14:26, 1 January 2020 by Jkinne (talk | contribs) (Problems)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

This page contains some classic beginning programming exercises. You should first complete most of the problems in Programming Assignments - Beginning 1 before working on problems on this page.

Problems

  1. head - read from standard input or a file and print only the first 5 lines of a file
  2. tail - read from standard input or a file and print only the last 5 lines of a file
  3. wc - read from standard input or a file and print the total number of characters, lines, and words
  4. stats - read numbers and print the smallest, largest, and average
  5. sort - read numbers, sort them (using any sorting algorithm), and print in sorted order
  6. csv1 - read a csv file and print how many rows and columns
  7. csv stats - read a csv file and print the stats (min, max, average) of one of the columns
  8. convert1 - convert between units (e.g., miles to/from km, degF to/from degC)
  9. convert2 - convert between units with the units to convert to/from as part of the parameter (e.g., parse text like "convert 1 mile to km" and do the conversion)
  10. arithmetic tables - print out arithmetic tables (for +, -, *, /)
  11. primes - print out specified number of primes (e.g., first 10 primes, first 100 primes)
  12. rectangle - print out a rectangle of *'s, optionally with blank interior
  13. triangle - print out a triangle of *'s, optionally with blank interior
  14. circle - print out a circle of *'s
  15. higher lower game - computer picks random number, asks user to guess, tells user if they are correct / too high / too low, keeps asking until they get it right, tells them how many guesses it took them
  16. tic tac toe - two player version running on the same computer, alternates asking for O and X's move, checks for a win and declares the winner or a tie
  17. list files - given a directory print a list of files in the directory, optionally including file size and last modified date/time
  18. directory tree - given a directory print the file contents as well as contents of all sub-directories
  19. change filenames - given a directory and file extension change all file names with the given extension in some specified way (e.g., put "OLD" on each filename)
  20. character count - read from standard input or a file and print how many times each character occurred
  21. random coin trials - flip 10 random coins some number of times (e.g., 1000 times), each time compute how often the coin was heads (will be between 0 and 10 for each trial), and compute the overall percentage of the time that each possible outcome occurred (normally 5 will be the most common outcome, but what percentage of the time does this occur).
  22. pascal's triangle - print pascal's triangle up to a specified row
  23. useful equations - look up the equations from math/physics to calculate each of the following - (a) from a given height above the Earth how far can you see (assume the Earth is a perfect sphere with radius 4000 miles), (b) from a given height above the Earth how fast will an object be traveling when it hits the ground if it is dropped (assume no air resistance and gravity is 9.8 m/s/s), (c) what is the mass of a given volume of air, (d) what is the volume of a given mass of gold
  24. approximate numbers - look up a summation formula for pi and use it to compute an approximation of pi (include the first 100 or 1000 terms in the summation), same for other irrational numbers (square root of 2, e)