Lab for Week 0 (Jan 3-5, 2011) ------------------------------- You will learn to operate on computers in this lab. 1. Basic commands as discussed in the class: * Login and logout * Opening a terminal * mkdir, rmdir, cd, pwd * touch, cp, mv, rm, ln * ls, more, cat, head, tail, wc, diff * chmod, passwd 2. Using Vi editor: create a file, save it and exit. 3. Create a file named as "firstProgram.c" using Vi and type-in the C program below. #include int main() { int a = 4, i = 5; int b, c, j; c = (b = a % 5) - (a = 1); printf("%d \n" , c); j = i++ * 2 - ++i * 2; printf("%d %d\n" , j, i); } Use the following command to create the executable: gcc -o myFirst firstProgram.c Then execute the program. 4. Create 3 different files: (i) "subtract_multiSrc.c", (ii) "multiply_multiSrc.c" and (iii) "multiSrc.c" for the following three programs. (i) int subtract(int a, int b) { return a-b; } (ii) int multiply(int a, int b) { return a*b; } (iii) #include extern subtract(int a, int b); extern multiply(int a, int b); int main() { int a = 10, b = 5; int c = subtract(a,b), d = multiply(a,b); printf("results are : %d and %d\n", c, d); } Now compile all three files together by using the following command gcc add_multiSrc.c multiply_multiSrc.c multisrc.c It will create a file "a.out" in your current directory. Execute this file by issuing "./a.out" command.