Programming Assignments - Beginning 2
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
- head - read from standard input or a file and print only the first 5 lines of a file
- tail - read from standard input or a file and print only the last 5 lines of a file
- wc - read from standard input or a file and print the total number of characters, lines, and words
- stats - read numbers and print the smallest, largest, and average
- sort - read numbers, sort them (using any sorting algorithm), and print in sorted order
- csv1 - read a csv file and print how many rows and columns
- csv stats - read a csv file and print the stats (min, max, average) of one of the columns
- convert1 - convert between units (e.g., miles to/from km, degF to/from degC)
- 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)
- arithmetic tables - print out arithmetic tables (for +, -, *, /)
- primes - print out specified number of primes (e.g., first 10 primes, first 100 primes)
- rectangle - print out a rectangle of *'s, optionally with blank interior
- triangle - print out a triangle of *'s, optionally with blank interior
- circle - print out a circle of *'s
- 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
- 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
- list files - given a directory print a list of files in the directory, optionally including file size and last modified date/time
- directory tree - given a directory print the file contents as well as contents of all sub-directories
- 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)