Homework 03: Variables and I/O
Name: _____________________________________________ Alpha: ___________________
Describe help received: ________________________________________________________
- Due before class on Wednesday, January 18
- This homework contains code to be submitted electronically.
Put your code in a folder called
hw03
and submit using the204sub
command. - This is an electronic homework and you do not need to print out anything to turn in during class.
Assignment
- Required reading: Section 3: Data representation and Section 4: I/O and type conversions from the Unit 2 class notes.
-
Write a program in a file called
checkout.c
that does a very simple grocery store checkout: it should read in the name of an item, the cost of that item, and how many of that item someone is buying. Then your program should print out a line like5 apples cost $3.55
showing the total cost.Example of running your program:
roche@ubuntu$
gcc checkout.c -o checkout
roche@ubuntu$
./checkout
Example input typed in to your program:
tacos 1.22 3
Example output from your program:
3 tacos cost $3.66
Submit your program in a file called
checkout.c
using the online submission system.Hint: Check out the C functions reference page for a quick reference on how to use the input/output commands you'll need.
Hint: The submit instructtions show how to submit code for the assignments in this class.