Homework 1
4-function Calculator

Due: Tuesday, October 31, 2006 at 11:59pm

Outcomes

After successfully completing this assignment, you will be able to...

Before Starting

Read Chapters 1-4

The Assignment

You are to write a C program that functions as a simple calculator. The program accepts commands of the form

operand operator

where

operand is a number of type float, and

operator is one of the characters:

After each command, the calculator performs the operation and prints out the value in the accumulator, or prints an error message.

Include files

Sample Execution


               Simple Calculator Program

(instructions to user go here...)

Enter your commands

==>10 S
= 10.000000

==>2       /
= 5.000000

==> 55  -
= -50.000000

==>100.25 S
= 100.250000

==>4 *
= 401.000000

==>0 E

Calculator program terminating...

Assumptions and Restrictions

You may assume that all input is in correct form, i.e. a number followed by one or more spaces, followed by a single-character command, followed by a newline. The program should be able to detect attempted division by zero, and be able to recover from the input of an illegal command.

Deliverables

From your Unix account, submit your C source code file using the following turnin command:

/cs/bin/turnin submit cs2301 hw1 hw1.c

Programs submitted after 11:59pm on October 31 will be tagged as late, and will be subject to the late homework policy.

Grading

For this assignment only, you may preview the grade sheet we will use when we grade your programs. Note that programs must compile successfully in order to receive points for Correctness.