next up previous
Next: About this document ...

Assignment 1: Introduction to CodeWarrior

Due: Wed. Oct. 8, 12:20

The main goal of this assignment is to introduce you to the CodeWarrior programming environment and to get you started programming in C. It is not a very long assignment but if you take this opportunity to get comfortable with the CodeWarrior interface and find out about its many features, future assignments will be easier. Please record the amount of time you spent on this assignment at the top right of the first page that you hand in(your grade has nothing to do with this number, but I'm interested to see how much time people spend on this).

This assignment has some reading and some programming. For the programming questions, make sure your code is well-commented as you were shown how to do in CS 100. Please hand in all of your code required by each programming question as well as the output from a sample run of your program.

1.
Read:

2.
Write a program which prompts the user for 2 integers. Print out the larger of the two.

3.
Write a program which reads in a sequence of integers terminated by -1 and prints out their squares and their cubes. At the end, print out the average of the numbers.

4.
Write a program which computes the interest (compounded annually) earned by a bank account. Prompt the user for the interest rate, the initial balance in the bank account, and the number of years the money will be left in the bank. For each year, print out how much money has accumulated. After you have run your program, the output should look something like this:

    Interest Rate: 0.05
    Starting Balance: 1000.00
    Years: 3

    Year      Balance
    1         $1050.00
    2         $1102.50
    3         $1157.62

You can truncate any partial cents. To restrict the number of digits that are printed out by printf, use the following form:

    printf(``%.2f'', balance)

Here, at most 2 digits of balance are printed out to the right of the decimal.



 
next up previous
Next: About this document ...

10/5/1997