wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Introduction To C Readings Chapters 1-3

Total questions: 36

Worksheet time: 18mins

Name
Class
Date
1.
What is the benefit of learning to use expert tools?
a)
They are easy to use.
b)
They often provide a graphical interface.
c)
At time 0, they are difficult to use.
d)
With time and effort, you can do more than with novice tools.
2.
In UNIX, what does the ~ symbol mean?
a)
The current directory
b)
The parent directory
c)
The user's home directory
d)
The end of prompt
3.
How would you access the manual page for the C library function printf?
a)
man printf
b)
man -S3 printf
c)
help printf
d)
man -c printf
4.
In your home directory (say your netID is gml8), you have a directory named `fintech` and two directories inside named `dira` and `dirb`. Your current working directory is `/home/gml8/fintech/dira`. Which one of the following uses a relative path to change to `dirb`?
a)
cd ~/fintech/dirb
b)
cd /home/gml8/fintech/dirb
c)
cd ../dirb
d)
cd dirb
5.
Assuming the same directories exist as in question 4, with your current working directory `~/fintech/dira`, how would you copy the file `code.c` from `dirb` to `dira`, renaming it `mycode.c`?
a)
cp ./mycode.c ../dirb/code.c
b)
cp ../dirb/code.c ./mycode.c
c)
mv ./mycode.c ../dirb/code.c
d)
mv ../dirb/code.c ./mycode.c
6.
On a UNIX system, all of the following are ways to view a myfile.txt EXCEPT:
a)
open myfile.txt
b)
less myfile.txt
c)
cat myfile.txt
d)
emacs myfile.txt
7.
What does Chapter 1 identify as the key aspect of programming?
a)
Accurate syntax
b)
Memorization of language features and library functions
c)
Metacognition
d)
Well-trained minions
8.
What is an algorithm?
a)
A clear set of steps to solve any instance of a particular class of problems.
b)
A mathematical function that helps you solve a specific problem.
c)
An American politician who warns about climate change.
d)
The output of a program.
9.
What is the disciplined fashion for algorithm development proposed by AoP?
a)
Start coding an example immediately.
b)
Work an instance, write steps, generalize, test.
c)
Work an instance, generalize, test new example, compare predictions.
d)
Work five instances and translate into math.
10.
If you are unable to complete Step 1 of the Seven Steps, which of the following could be a viable path forward?
a)
Consult language references for useful library functions.
b)
Ask a mathematician for a sequence function.
c)
Gain more domain knowledge for the problem's domain.
d)
Skip Step 1 and move on to writing code.
11.
What are parameters?
a)
Assumed conditions under which an algorithm is written.
b)
Lines of code like 'if' that let the program make decisions.
c)
Symbolic placeholders for values specifying the instance of the problem.
d)
Invariants describing mathematical relationships guaranteed to be true.
12.
What is the purpose of Step 4 of the Seven Steps?
a)
Ensure sufficient test cases for Step 6.
b)
Find anything not generalized correctly before writing code.
c)
Pre-create hypotheses for Step 7.
d)
Identify language constructs and library functions to use.
13.
What is the problem that AoP identifies with the PB&J example?
a)
Embarrassing students discourages them.
b)
It wouldn't type-check in a language.
c)
It solves one specific problem, not a general class.
d)
It exaggerates the computer’s discretion to misinterpret instructions.
14.
Why will you work with many numerical/mathematical problems/examples?
a)
Computers can only operate on numbers.
b)
Math problems are easier to write.
c)
Math-based problems are inherently more precise than word-based problems.
d)
People usually use computers for numerical calculation.
15.
What are corner cases?
a)
Combinations of parameter values that require special handling
b)
Patterns difficult to find due to non-linear nature
c)
Syntax errors that crash the program
d)
Triangular storage units
16.
If you were writing a sandwich making algorithm, how would you deal with someone trying to use it to make a battleship sandwich?
a)
Explicitly check for such errors.
b)
It's the wrong type of input; the algorithm needn't handle it.
c)
Ignore it and follow the normal algorithm.
d)
Ensure your algorithm uses 'common sense'.
17.
What does the term "semantics" mean in the context of programming?
a)
Rules for constructing grammatically correct programs.
b)
Rules describing the meaning of syntactically correct code.
c)
Rules for fixing problems with broken code.
d)
Rules for dividing code into functions.
18.
Consider the following piece of code: ```c int f(int x, int y) { temp = 3 * x + y * y; return (temp - x) / 2; } ``` Which of the following best describes the syntax error in this piece of code?
a)
It makes use of an undeclared variable.
b)
Incorrect use of parenthesis.
c)
(temp - x) / 2 is not a valid expression.
d)
Parameters to f are declared improperly.
19.
What is an `lvalue`?
a)
A value that can be placed into a box.
b)
A value elevated through evaluation of an expression.
c)
An expression that can appear on the left side of an assignment.
d)
None of the above
20.
What symbol ends statements in C?
a)
A period
b)
A comma
c)
A colon
d)
A semicolon
21.
What does `scope` mean?
a)
The types of values a variable can hold.
b)
The region of code in which a variable is visible.
c)
The kinds of problem a function can solve.
d)
The amount of domain knowledge required to program.
22.
What does the `%d` format specifier mean for printf?
a)
Print an integer in base 10
b)
Print arbitrary data in its native format
c)
Print the current date
d)
Print a string
23.
What is the difference between printing a value and returning a value?
a)
Printing leaves the function; returning does not.
b)
Printing gives it to the user; returning gives it to other code.
c)
Printing only works on strings; returning only on ints.
d)
None of the above.
24.
What are the semantics of `break`?
a)
It causes the program to crash.
b)
It exits the current function, destroying its frame.
c)
It moves execution just outside the current loop or switch.
d)
None of the above.
25.
If C did not have the keyword `for` but you wanted to write something where a for-loop were the natural choice, what could you use instead?
a)
if
b)
while
c)
return
d)
break
26.
Suppose you have the line of code ```c int a = f(x,y); ``` Which of the following best describes how you determine what value to put in the box for `a`?
a)
Look at f as a math function; compute x,y; put result in a.
b)
Execute f; when printf prints a number, that's a.
c)
Find where 'a = expression' occurs in f; use that value.
d)
Create a frame for f, execute, and use the value of 'return expression;'.
27.
What is abstraction?
a)
Removal of the non-essential parts of a program.
b)
Moving from concrete examples to more general cases.
c)
Separation of what something does from how it does it.
d)
None of the above.
28.
If the most significant bit of a signed integer is a 1, then what kind of number is it?
a)
Negative
b)
Zero
c)
Positive
d)
Infinity
29.
What is a `struct`?
a)
A construct that changes control flow.
b)
A construct for special in"struct"ions.
c)
A construct to change how frames are con"struct"ed.
d)
None of the above
30.
What does `typedef` do?
a)
Defines a new type.
b)
Makes another name for an existing type.
c)
Creates a typed external file.
d)
None of the above.
31.
Which of the following could be represented with a `float` but not with an `int`?
a)
1000
b)
-42
c)
4.2
d)
0
32.
Which of the following is true of `casting` a value?
a)
I and III
b)
I and II
c)
II and III
d)
I, II, and III
33.
What is a string?
a)
A fragment of code with no control statements.
b)
A chain of computations affecting the same variable.
c)
A pattern of bits with an odd number of ones.
d)
A sequence of characters
34.
Which of the following is NOT determined by the type of a variable:
a)
The number of bits needed to store it.
b)
How to interpret/operate on those bits.
c)
The scope of the variable.
d)
None of the above (all are determined by the type).
35.
What does `hex` mean?
a)
Base 4
b)
Base 8
c)
Base 16
d)
Base 64
36.
Which of the following are represented numerically?
a)
Images
b)
Sound
c)
Video
d)
All of the above