CS113: Homework 1

Turn in a PRINTOUT of your program (no sample data necessary) with your full name and netID, in class; AND, e-mail the source code (and only the source code) to oneill+assign1@cs.cornell.edu.

Please create a separate .c file for each problem. (For example, for this assignment you should send me three files named something like biggest.c, graph.c, and coins.c.)

DO NOT just e-mail me your source code. YOU MUST turn in a printout of the code to receive credit for the assignment.

Problem: Find the biggest

Write a program that prints out the two highest nonnegative integers that the user has typed in. The user should be able to input a sequence of nonnegative integers separated by carriage returns, terminated by a negative integer. You may assume that the user inputs at least two nonnegative integers, and only inputs integers.

Here's a sample interaction with my program:

Enter some numbers:
3
2
6
13
-8
The two biggest numbers were 13 and 6.

Problem: Couting Coins

Write a program that accepts a dollar amount (in cents) and computes the number of quarters, nickels, dimes and pennies needed. Your solution must use the fewest number of coins that are possible for the given dollar amount.

You may assume that the input is an integer amount greater than 0.

Here are some sample interactions with my program; your program should give identical output.

Enter a dollar amount (in cents): 50
You need:
* 2 quarters

Enter a dollar amount (in cents): 96
You need:
* 3 quarters
* 2 dimes
* 1 penny

Problem: Printing graph paper

Write a program that creates graph paper with user-specified dimensions. Your program should query the user for four positive integers: the height and width of the paper in terms of the number of squares, and the height and width of each square. You may assume that the height and width of each square is greater than 1, and that the height and width of the number of boxes is greater than 0. The graph paper should be output using the "+", "-", and "|" characters, as in the examples below. (Note: If you can't find or don't have these three characters on your keyboard, you may substitute any others - but you must use three distinct characters.) Here are some sample interactions with my program; your program should give identical output.

Enter height (number of boxes): 3
Enter width (number of boxes): 4
Enter height of a box: 2
Enter width of a box: 3
+--+--+--+--+
|  |  |  |  |
+--+--+--+--+
|  |  |  |  |
+--+--+--+--+
|  |  |  |  |
+--+--+--+--+


Enter height (number of boxes): 1
Enter width (number of boxes): 2
Enter height of a box: 3
Enter width of a box: 3
+--+--+
|  |  |
|  |  |
+--+--+


Enter height (number of boxes): 2
Enter width (number of boxes): 1
Enter height of a box: 3
Enter width of a box: 6
+-----+
|     |
|     |
+-----+
|     |
|     |
+-----+


Enter height (number of boxes): 2
Enter width (number of boxes): 4
Enter height of a box: 3
Enter width of a box: 6
+-----+-----+-----+-----+
|     |     |     |     |
|     |     |     |     |
+-----+-----+-----+-----+
|     |     |     |     |
|     |     |     |     |
+-----+-----+-----+-----+