Assignment 1, CS2101a 2012

Posted date: Tuesday, September 25, 2012

Due date: 11:59pm, Tuesday, October 9, 2012

This assignment consists of three parts.

Part one is a first experience with writing a C program interacting with the user. Here, we would like students to experience command line input, and to understand and use C types such as int and float, as well as the flow control structures.

Part two is an introduction to performance issues with programs, more precisely with scalability and data locality.

Part three provides you with a list of standard questions on UNIX and shell commands.

Please, read carefully the Assignment Submission Guidelines.

Part one: (30%)

The goal of the exercise is to implement a simple calculator, called "calculator". and which works as follows.

(1) First, the user is asked what she/he wants to do. Three characters can be entered, each corresponding to a possible action.

q for quit

a for addition

m for multiplication

(2) In case of a or m, the program asks the type of the operands

f for float

i for int

(3) Then the program asks for the two operands, displays the result and returns to Step (1).

You are asked to write a C program implementing this calculator. Your program should handle non-valid input values. More precisely, you should consider the cases where the user

However, we assume that the user will always enter valid operands at Step (3).

Part two: (40 %)

The goal of the exercise is to experiment with the performance degradation caused by high rate of cache misses. To this end, you are required to implement a well-known algorithm for sorting integer numbers and try it on larger and larger input data sets.

This algorithm is the counting sort algorithm. At its wikipedia page, you will find a detailed description of this algorithm.

Part three: (30 %)

In this exercise, you are required to give a shell command line for each of the following 14 questions.
Note: for each question below, please test it once and record your test runs using the script command.