# 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)*character count*- read from standard input or a file and print how many times each character occurred*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).*pascal's triangle*- print pascal's triangle up to a specified row*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*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)