# CS 200 - Assignment 1

Due: Tuesday, September 18th by 11:59 PM

Write a program that solicits numbers of pennies, nickels, dimes, and quarters from the user and computes the total value in cents.

An example run of the program should look something like this.  (Things that the user types are in bold red.)

`Number of pennies: 8Number of nickels: 3Number of dimes: 5Number of quarters: 2That is worth 123 cent(s)`

## Getting Started

Download CS200_Assign1.zip.  Extract the contents of the zip file.  You will modify the code in the file Coins.c.

If you are using Visual Studio, double click on the file CS200_Assign1.sln.  This will launch Visual Studio.  You can compile the program

If you are using Mac OS or Linux, open a terminal window and navigate to the directory containing the file called Makefile.  You should be able to run the command make in the terminal window, which will compile the program and produce an executable called CS200_Assign1.exe.  Once the program has been compiled, you should be able to run the program in the terminal window by typing the command

`./CS200_Assign1.exe`

You should store the number of each kind of coin (pennies, nickels, etc.) in a different variable.  Use int as the type of each variable.

Say that you are using a variable called num_pennies to store the number of pennies.  You can prompt the user for the number of pennies as follows:

`printf("Number of pennies: ");scanf("%i", &num_pennies);`

## Integer arithmetic

In C, addition and multiplication are performed using the + and * operators.  A chunk of C code that computes a value is called an expression.  The + and * operators allow you to construct expressions that perform addition and multiplication, respectively.

For example, say that the variable num_quarters contains the number of quarters entered by the user.  The C expression

`num_quarters * 25`

computes an integer value that is the number of cents that the quarters are worth.

For example, you could use the above expression to calculate how much the user's quarters are worth and assign the resulting value to a variable:

`int num_quarters;int value_of_quarters;/* ... code that reads a value from the user into the num_quarters variable... */value_of_quarters = num_quarters * 25;`

You can also print the computed value using the printf function (see below).

## Printing integer values

Once you have computed an integer value, you can print it using the printf function.  For example, the C statement

`printf("your quarters are worth %i cents\n", num_quarters * 25);`

prints a message indicating how much the user's quarters are worth.  The %i character is a placeholder which is substituted with the value of the expression num_quarters * 25 when the message is printed.

## Testing the program

Run the program and type in several combinations of coins.  Make sure the program produces the correct output.

## Submitting

See the submission instructions.  This assignment is Project 1.