
CGS 3460 - Programming Using C
Summer 2009
Assignment #3
20 Points
Assigned: 05/29/2009, Friday
Due: 06/4/2009, Thu, 11:59 PM
1. (5 Points) Write a program that will take a dollar amount such as $2436.37, and
break it down into bill and coin amounts, i.e., bills for $1000, $100, $50, $20, $10,
$5, $1, and coins: quarters, dimes, nickels, pennies. Assume a maximum amount
of $9999.99. Express the number of the denominations numerically, e.g., 1 $1000
bill, 3 $100 bills, etc. Use the conditional expression to print bill or bills. Save as
p1.c
2. (5 Points) Write a program the reads in the lengths of the three sides of a
triangle(you may assume integer lengths). First, verify that the lengths do form a
triangle: adding any two sides should yield a number that exceeds the third. Next,
determine if the triangle is equilateral: all sides would have equal length. Next,
determine if the triangle is isosceles: two sides have equal length, which is
different from the third. Finally, determine if the triangle is right-angled: the sum
of the square of two sides would yield the square of the third. Save as p2.c
3. (5 Points)Write a program that reads in a positive integer N and prints out all
combinations of 3 POSITIVE WHOLE numbers that add up to N. Save as p3.c Hint:
Use 3 nested loops
4. (5 Points)The factorial function is defined by f(n) = n(n-1)(n-2)...(3)(2)(1). Write a
program that will read in a positive integer N and calculate the factorial of n. Save
as p4.c Consider what happens when you enter large values of N.
Instructions for submitting Assignment 3
1. First compress your program files into a tar file. For this, change to the directory where
you have stored both the files. At the terminal command prompt (putty, Linux console,
MAC terminal, etc.) type:
tar cvf assign3.tar p1.c p2.c p3.c p4.c
Let’s say you have stored your files in assign3 directory on your “rain” machine.
> cd assign3
> ls
p1.c
p2.c