Docsity

Midterm Exam - System Level Programming | CSC 3320, Exams of Computer Science

Toggle sidebar
bg1
CSc 3320
Ken D. Nguyen
Summer, 2001
Midterm
July 02, 2001
Name:____________________________
Note: send me an email if you want your grade sent to you
Grading scale A = 70 -> 100 (5)
B = 55 -> 70 (3)
C = 35 -> 55 (12)
D = 20 -> 35 (4)
I. Circle the correct answer(s), solution in bold
1. UNIX shares
a. CPU time
b. Memory
c. Peripherals
d. Disk space
e. b, c and d only
f. c and d only
g. a, b, c, and d
2 points
2. $ is a
a. csh prompt
b. csh command
c. ksh prompt
d. ksh command
e. tsh prompt
f. tsh command
2 points
3. To send an interrupt signal to terminate a running process we
use
a. ^D
b. ^C
c. ^Z
d. ^H
e. exit
2 points
4. Files that have names start with a
a. .
b. ..
c. *
d. @
pf3
pf4
pf5
Discount

On special offer

Partial preview of the text

Download Midterm Exam - System Level Programming | CSC 3320 and more Exams Computer Science in PDF only on Docsity!

CSc 3320 Ken D. Nguyen Summer, 2001 Midterm July 02, 2001 Name:____________________________ Note: send me an email if you want your grade sent to you Grading scale A = 70 -> 100 (5) B = 55 -> 70 (3) C = 35 -> 55 (12) D = 20 -> 35 (4) I. Circle the correct answer(s), solution in bold

  1. UNIX shares a. CPU time b. Memory c. Peripherals d. Disk space e. b, c and d only f. c and d only g. a, b, c, and d 2 points
  2. $ is a a. csh prompt b. csh command c. ksh prompt d. ksh command e. tsh prompt f. tsh command 2 points
  3. To send an interrupt signal to terminate a running process we use a. ^D b. ^C c. ^Z d. ^H e. exit 2 points
  4. Files that have names start with a a.. b. .. c. * d. @

are hidden files 2 points

  1. The junk/ directory and its contain can be remove by a. rmdir junk b. rm junk c. rmdir –r junk d. rm –r junk e. rmdir –r junk/* f. rm –r junk/* 2 points
  2. in C, a string is an array of characters ending by a a. ‘NULL’ b. ‘\0’ c. ‘\n’ d. ^D e. ^M 2 points II. Give a command, a group of commands or UNIX utilities that will
  3. provide you the same functionality of the “page” utility (2 points) more
  4. list all phonedir.x files, where x must be any readable single character , in the current working directory(2 points) ls phonedir.?
  5. create the public_html/cgi-bin/junk directory structure, (assume that you have no knowledge of the existence of the above directories). (2 points) mkdir –p public_html/cgi-bin/junk
  6. print the number of the user in the system, (assume that each user will be an entry(a line) in the file /etc/passwd ) (2 points) wc –l /etc/passwd
  7. find all the user in the system, store the result into file user.out, and display the result in sorted order. ( 4 points) who | tee user.out | sort
  8. show all of your running processes (2 points) ps (For the following questions, assume that you are editing the phonedir.c file by vi editor and in the command mode)
  9. delete the first 3 lines of the file (2 points) :1,3d
  10. delete the last 3 lines of the file (2 points) :$-2,$d
  11. copy lines 5-10 and paste after line 15 (3 points) :5,10y :15pu

for(i = 0; i < 10; i++) printf(“%d \t”, b[i]); 10 9 8 7 6 5 4 3 2 1

  1. char str1[6] = “abd”; (3 points) printf(“%d, %d”, strlen(str1), sizeof(str1)); 3, 6
  2. struct Part { int number; int onhand;}; ( 3 points) Part part1= {3000, 15}, part2 = {1250, 0}; printf(“Part number = %d, on hand = %d”, part1.number, part1.onhand); syntax error
  3. union{ int onhand; float price;} price; ( 5 points) a. printf(“Union size = %d”, sizeof(price)); Union size = 4 b. printf (“Union size = %d”, price.size()); syntax error IV. Answer the following questions
  4. A function prototype declared as void func(); will take how many parameters? depends on the definition of func (3 points)
  5. What should be the first line in your csh script ?( 3 points) #! /bin/csh
  6. What is the effect of the shift command embedded in your script? (3 points) Shift the input parameters to the left by 1
  7. #define MAX_SIZE 100; (3 points) int a [MAX_SIZE]; What will be substituted into the place of MAX_SIZE in the declaration of array a? 100;
  8. An array name can be used as a pointer. TRUE / FALSE (3 points) TRUE
  9. A pointer can be used as an array as long as it points to an array. TRUE / FALSE TRUE (3 points)
  1. In C language, declare and define a function called sum that takes a pointer to an array of integer, a lower bound array index and a upper bound array index as parameters, and returns the sum of all the values in the pointed array from the lower bound to upper bound indexes, (the sum includes the values at both boundaries). The function must guarantee, in its prototype, that the values of the array will not be altered. (11 points) int sum(const int p, int l, int h); / function prototype / / funtion definition/ int sum(const intp, int l, int h){ int i, total = 0; for(i=l; p+i <= p+h; i++) total += (p+i); return total; }*