Previous: 2.1 A Simple C Program
Up: 2.1 A Simple C Program
Next: 2.1.2 Translating the Algorithm to C
Previous Page: 2.1 A Simple C Program
In the previous chapter we introduced a payroll task which can be summarized as a task to calculate pay for a number of people employed by a company. Let us assume that each employee is identified by an id number and that his/her pay is computed in terms of an hourly rate of pay. We will start with a simple version of this task and progress to more complex versions. The simplest version of our task can be stated as follows.
PAY0: Given the hours worked and rate of pay, write a program to compute the pay for a person with a specified id number. Print out the data and the pay.
The algorithm in this case is very simple:
print title of program;
set the data: set id number, hours worked, and rate of pay;
set pay to the product of hours worked and rate of pay;
print the data and the results;
With this algorithm, it should be possible, without too much trouble, to implement the corresponding program in almost any language since the fundamental constructs of most algorithmic programming languages are similar. While we will discuss the features of C, similar features are usually available for most high level languages.