Download Comp 211 Midterm 1, Spring 2025 and more Exams Computer Science in PDF only on Docsity!
Midterm 1 - A
COMP 211: Systems Fundamentals
Spring 2025
February 14, 2025
Name:
9-digit PID:
Do not begin until given permission.
Honor Code: I have neither given nor received any unauthorized aid on this assessment.
Signed:
Question 1: Git Fill in the bubble next to your answer. Each question expects one answer.
1.1. A remote in git is a
⃝ A backup repository that Git
creates automatically
⃝ A repository you push to / pull
from
⃝ A local branch in your repository
⃝ A hidden directory where Git
stores commit history
1.2. rm hello.c will remove hello.c from
your working directory and your git com-
mit history.
⃝ True
⃝ False
1.3. What is gh-pages in the command:
git push origin gh-pages
⃝ a repository
⃝ a remote
⃝ a commit ID
⃝ a branch
1.4. In the process of forming a commit, into
what area are you git add-ing files to?
⃝ holding
⃝ staging
⃝ stashing
⃝ boxing
1.5. Running git fetch will sync your local
repository with a remote and merge your
current branch with the equivalent branch
on the remote.
⃝ True
⃝ False
1.6. The significance of HEAD is that when you
make a new commit, the branch HEAD
refers to is updated to refer to the new
commit.
⃝ True
⃝ False
1.7. When you git switch to a branch you’re
not currently working on, your repository’s
HEAD reference changes.
⃝ True
⃝ False
1.8. Which command creates a new branch
AND switches to it?
⃝ git merge new-feature
⃝ git switch -c new-feature
⃝ git checkout branch
new-feature
⃝ git branch new-feature
1.9. A merge commit in git has more than one
parent commit.
⃝ True
⃝ False
1.10. When HEAD refers to feature-1 and you
successfully run git merge feature-2,
which branch moves?
⃝ feature-
⃝ feature-
⃝ Neither
⃝ Both
1.11. A fast-forward merge deletes the com-
mit history of the merged branch, while a
merge commit preserves all commit history
from both branches.
⃝ True
⃝ False
1.12. A git branch:
⃝ Cannot be merged with other
branches
⃝ Is a protected copy of the
repository separate from other
branches
⃝ Is a pointer to a commit ID
⃝ Has a distinct commit history
with some difference(s) com-
pared to all other branches
Question 3: C Programming We want to write a program that reads characters from standard
input until the end-of-file (EOF) is encountered. For each uppercase letter (’A’ to ’Z’), we want to
print some information about the letter. Below is an attempted implementation of this program.
1 # include < stdio .h >
2 # include < stdlib .h >
4 int main () {
5 int c ;
6 while (( c = getchar () ) != EOF ) {
7 if ( c <= ’A ’ || c >= ’Z ’) {
8 printf ("% c , %d , %c , % d \ n " , c , c , c - ’A ’ , c - ’A ’) ;
11 return EXIT_SUCCESS ;
3.1. There is an error on line 7. Rewrite the line of code so that it performs the intended operation.
3.2. After applying your correction, what output will the program produce for the input "bK{"?
3.3. What output would the original (uncorrected) program produce for the same input "bK{"?
Question 4: Command-line Interface For the questions below, assume the following directory
structure:
/Projects
|-- Dev
| ‘-- Code
| ‘-- app.py
|-- Docs
| ‘-- readme.md
‘-- Tests
‘-- test_app.py
Assume the current working directory is /Projects/Dev.
4.1. Move test_app.py to the Code directory using relative paths for both the source and destina-
tion.
4.2. Append the text "Part 1" to readme.md without overwriting its existing content using only one
command. You may use relative or absolute paths.
4.3. Copy readme.md from the Docs directory to the Dev directory using absolute paths for both the
source and destination.
4.4. Rename app.py to main.py using one command. Remember, the current working directory is
/Projects/Dev. You may use relative or absolute paths.
Dec Hex Char Dec Hex Char Dec Hex Char Dec Hex Char 0 0 NUL (null) 32 20 Space 64 40 @ 96 60 ’ 1 1 SOH (start of heading) 33 21! 65 41 A 97 61 a 2 2 STX (start of text) 34 22 " 66 42 B 98 62 b 3 3 ETX (end of text) 35 23 # 67 43 C 99 63 c 4 4 EOT (end of transmission)
36 24 $ 68 44 D 100 64 d
5 5 ENQ (enquiry) 37 25 % 69 45 E 101 65 e 6 6 ACK (acknowledge) 38 26 & 70 46 F 102 66 f 7 7 BEL (bell) 39 27 ’ 71 47 G 103 67 g 8 8 BS (backspace) 40 28 ( 72 48 H 104 68 h 9 9 TAB (horizontal tab) 41 29 ) 73 49 I 105 69 i 10 A \n (newline) 42 2A * 74 4A J 106 6A j 11 B VT (vertical tab) 43 2B + 75 4B K 107 6B k 12 C FF (NP form feed, new page)
44 2C , 76 4C L 108 6C l
13 D CR (carriage return) 45 2D - 77 4D M 109 6D m 14 E SO (shift out) 46 2E. 78 4E N 110 6E n 15 F SI (shift in) 47 2F / 79 4F O 111 6F o 16 10 DLE (data link escape) 48 30 0 80 50 P 112 70 p 17 11 DC1 (device control 1) 49 31 1 81 51 Q 113 71 q 18 12 DC2 (device control 2) 50 32 2 82 52 R 114 72 r 19 13 DC3 (device control 3) 51 33 3 83 53 S 115 73 s 20 14 DC4 (device control 4) 52 34 4 84 54 T 116 74 t 21 15 NAK (negative acknowledge)
53 35 5 85 55 U 117 75 u
22 16 SYN (synchronous idle) 54 36 6 86 56 V 118 76 v 23 17 ETB (end of trans. block)
55 37 7 87 57 W 119 77 w
24 18 CAN (cancel) 56 38 8 88 58 X 120 78 x 25 19 EM (end of medium) 57 39 9 89 59 Y 121 79 y 26 1A SUB (substitute) 58 3A : 90 5A Z 122 7A z 27 1B ESC (escape) 59 3B ; 91 5B [ 123 7B { 28 1C FS (file separator) 60 3C < 92 5C \ 124 7C | 29 1D GS (group separator) 61 3D = 93 5D ] 125 7D } 30 1E RS (record separator) 62 3E > 94 5E ˆ 126 7E ∼ 31 1F US (unit separator) 63 3F? 95 5F _ 127 3F DEL
Table 1: ASCII Character Table
This page intentionally left blank.