Programming in C
autumn 2010
Exercise 5
Tell the project work your group have chosen using courses Moodle discussion area Oct. 5th at the latest. It is enough that one of the group members informs the project work of the group and the names of members.
The group may have 2-3 students.
Signing up for the first time in the course moodle area you need the word htyo.
To the exam you may take one A4 paper, where you have made your own notes.
You can use both sides of the paper.
Oct. 7th 2010
- Make a implementation of an event list.
The
event list contains all the events (customer arrives in queue, customer
leaves checkout etc.) in chronological order.
The list has a header node and it is an ordered (by time) singly
linked list. Think what kind of operations you will need and implement them.
You can find some information about
Discrete event simulation from wikipedia.
- Write a main program, which you can use to test the functions
of the first assignment.
- (11-12)
In this exercise we use a binary file "fname" storing information
about employees. For each employee, store the name,
the identification number and a salary:
struct employee {
long id;
char name[50];
double salary;
};
Write the following functions:
-
int add (fname, empId, stringName, salary), where
fname is a string representing a binary file
empId is an integer,
stringname is a string, and a
salary is a double.
This function appends a new employee to the binary file
(an empId is akey and uniquely identifies an employee;
therefore this function may fail)
-
void moreDollars (fname, empId, incr), with three parameters: a string
fname, an integer empId, and a double incr.
This function operates on a binary file fname, and it increases by
incr the salary of every employee whode id is greater than or equal to
empId.
-
void show (const char *fname) that shows all the information stored
in the binary file fname
- (12-3)
Write a data type Elem
to store either an integer or a character (but not both).
Then, write a program which reads values from standard input and
when it finds integers, stores them ia the array of Elem's.
Should the reading of an integer fail, the program will read a sigle character,
store it, and continue processing.
Reading should terminate when either end-of-file has encountered,
or 100 items have been read.
Your program should output in inverse order all integers which
have been stored.
For the input
12 b3 6g
array will store
12
b
3
6
g
and the output will be:
6 3 12
Returnable homework (one module from your project work):
-
Make an implementation of a module related to your project work,
either alone or with your group. For example, a data structure you need
for your work.
- Write a main program that allows test your module.
Return the tasks to Moodle latest Oct. 8th.
Of these you get a total of up to two points.
About these tasks you get feedback during following week from other
students.
Study also:
- Classification functions to charaters and string functions
- Arrays (Example 10.2 maxMin)