C programming HW
COMP-3130-01
C Programming
Assignment-1
Due on 02/04/2015
|
|
|
|
Name: |
Signature:
|
1. Write a C program that asks the user to enter a U.S dollar amount and then shows how to pay that amount using the smallest number of $20, $10, $5, $1, quarters, dimes, nickels, and pennies.
For example:
Enter a dollar amount: $78.49
$20 bills: 3
$10 bills: 1
$5 bills: 1
$1 bills: 3
Quarters: 1
Dimes: 2
Nickels: 0
Pennies: 4
Enter $25.24 and $99.99 to test your program and print your screenshots.
2. Write a C program that reads an integer entered by the user and displays it in octal (base 8). The output should be displayed using five (5) digits, even if fewer digits are sufficient. Hint: To convert a number to octal, first divide it by 8; the remainder is the last digit of the octal number. Then divide the quotient by 8 and repeat the process to arrive at the next digit. (Do not use built-in C function to solve this problem. You must code it).
For example:
Enter a number between 0 and 32767: 2016
In octal, your number is: 03740
Enter 8 and 7999 to test your program and print your screenshots.
Requirements for assignment reports
· The cover page must be attached.
· For each programming question, the submission must contain the program itself printed out from the IDE, description of the input and output of the program, and running page (screen shot) which shows that the program works for all cases.
· Each program must have proper comments lines for non-trivial so that the instructors can read and understand the your code.
Page 1 of 3