Assignment 1, CS211b 2011

Posted date: Tuesday, January 25, 2011

Due date: 11:59pm, Tuesday, February 8, 2011

Submission Instructions

Please refer to the Assignments submission guidelines on the course web site here. A brief summary follows. Submiy your programs and script files electronically. Put your completed assignment (that is, the printing of your programs and script files) in an envelope labelled with your name and course number CS2211b. Print an assignment ticket as described here and put it inside the envelope along with your assignment. Hand in your envelope (contained with your completed assignment and the assignment ticket) in class, or drop it in the CS2210b locker (locker 89, on the ground floor of the Middlesex College building) by the midnight on the due date.

Assignment overview

This assignment consists of two parts.

In part one, you are required to write a C programs (ready to have fun in C?). 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 studied in class.

Part two provides you with a list of exercises on UNIX and shell commands.

Pease, read carefully the Assignment Submission Guidelines

Part one: (50%)

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: (50 %)

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

In this assignment, you are asked to do the following (please do it in order) :

1. Inside the directory ~/CS211/Asn1/ (if you do not have such a directory, create one), create a folder whose name is your uwo username

2. list all the files under ~/CS211/Asn1/ such that the folder you just created is listed at the bottom

3. cd to the folder you just created.
Use one command to create a file a.txt, whose content is: hello
Create another file b.txt, whose content is: world
Concatenate the two files together and name the new file as c.txt

4. give at least two ways to display the content of the file a.txt

5. rename c.txt as d.txt
create a subfolder with the name hello inside the current folder

6. copy d.txt into the folder hello

7. remove the whole folder hello

8. create a symbolic link with name c.txt and pointing to d.txt

9. without leaving the current directory, use two ways to print your home directory

10. find all files with the name d.txt inside your home directory

11. print the type of the file d.txt

12. give the user execute permission for the file d.txt

13. Create the folder hello again and then use one command to cp all files ending with .txt to the folder hello

14. gives the group user executable access only to those files already executable in the current folder and its subfolder hello