

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Practice midterm questions for a computer science course, covering unix commands, writing a c program, understanding recursion, and converting data representations. Students will learn how to cancel a print job, list files, set file permissions, move files, view files, write a program to find common factors, analyze a recursive function, and interpret if statements. They will also practice converting binary and hexadecimal numbers to decimal.
Typology: Quizzes
1 / 3
This page cannot be seen from the preview
Don't miss anything!


a. (10 points) You just printed something to printer hexus, and find that it's printing a bunch of garbage. What are the steps you take to cancel the print job?
b. (5 points) What UNIX command would you type to see a list of all of the files (including the hidden files) in directory hw1?
c. (5 points) You just wrote and saved the file test2.c. Now you want to make sure that only you can read and write it. What UNIX command would you type to make test.c only readable and writeable by you?
d. (5 points) You want to move all of your C source files (ending in .c) and header files (ending in .h) from your hw1 subdirectory to your mid1 subdirectory. What UNIX command should you type?
e. (5 points) You want to view the file test3.c a screen at a time. What UNIX command would you type?
Please enter two positive integers: 20 12 1 2 4
Please enter two positive integers: 60 120 1 2 3 4 5 6 10 12 15 20 30 60
Please enter two positive integers: 8 9 1
Please enter two positive integers: 0 230 Done.
void pb(int n) { if (n != 0) { pb(n / 2); putchar('0' + n %2); } }
___ans = 2 * 4 / 7 - 2 + 3 - 4 % 7; ___ans = (++a == --b) + 3 * c++; ___ans = (7 / 4 + 4 / 7) * 3 / 4.0 * 8 ; ___ans = 7 < 8 && 8 > 6 || 4 == 4 && !(6 < 5); ___ans = (4 == 4) + ((7 > 7) * 3 || 6 % 3) * 5 + !(6 < 5) * 7;
if (X > 20) printf(“First ”); else if (X < 5) printf(“Second “); else printf(“Third “); if (X == 20) printf(“Fourth “); else if (X < 19 || X > 25) printf(“Fifth “); if (X > 5 && X < 22) printf(“Sixth ”);
a.) (5 points) X = 0 ________ b.) (5 points) X = 5 ________ c.) (5 points) X = 17 ________ d.) (5 points) X = 20 ________ e.) (5 points) X = 28 ________
whole.out : one.o, two.o, three.o gcc -o whole.out one.o two.o three.o
one.o : one.c whole.h one.h two.h