Docsity

CGS 3460 Assignment 3: Programming Challenges in C, Assignments of Computer Science

Toggle sidebar
bg1
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
pf2

Partial preview of the text

Download CGS 3460 Assignment 3: Programming Challenges in C and more Assignments Computer Science in PDF only on Docsity!

CGS 3460 - Programming Using C

Summer 2009

Assignment # 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 $ 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
  5. 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 assign ls p1.c p2.c

p3.c p4.c ..

tar cvf assign3.tar p1.c p2.c p3.c p4.c ls p1.c p2.c p3.c p4.c assign3.tar ….

  1. If you are working from Windows platform using Putty and WinSCP, you can create a directory assign3 in your home directory on rain machine using putty. Create the directory using this command on putty

    cd //to change to the home directory mkdir assign3 //to create the directory under home directory

  2. Then transfer p1.c, p2.c, p3.c and p4.c to assign3 directory on rain using WinSCP.
  3. Go to step 1 to tar the file using putty.
  4. Use WinSCP to copy assign3.tar from rain machine back to your local computer, say desktop.
  5. Upload the assign3.tar to WebCT.
  6. Please check the discussion page for assignment 3 on WebCT for common questions and their answers.