Microsoft Word – SU 2021 Midterm Study Sheet
CSE 2421 – Summer 2021 Midterm Study Sheet
1. Along with your midterm, you will receive a C programming language Operator Precedence
chart, an I/O format string reference for scanf() and printf(), a list of C keywords, and (if exam
questions dictate) an ASCII character sheet reference. Prior to the midterm, you can find these
references within the slides or in the Midterm section on Piazza. You should make a point of
reviewing these items prior to the exam so that, should you need to refer to them during your
exam, you can do so quickly and efficiently.
2. Did you keep up with the Required Readings included in the slides? I hope so!
3. Did you read any of the articles in the General Reference section of Piazza? If not, maybe you
should.
4. Did you bother to take a look at any of the C language Sample programs?
5. Can you work your way around in gdb? What does break do? How might one set a breakpoint?
You should know at least 2 different ways to set a breakpoint. How might one run a program
with gdb? How does one work with command line arguments within gdb? Do you know how to
redirect input so that it comes from a file while you are running a program in gdb? What does
“continue” do? Do you know how to find the value of a declared variable? Do you know how to
print in in hexadecimal rather than decimal? How about the value of structure elements? Any
basic gdb command is fair game. You should also be able to use gdb information to figure out a
“bug” in a simple piece of code.
6. Any concepts addressed in Lab1 through Lab4 (this means you’ve coded it by the time of the
midterm) would be reasonable questions.
7. Any concepts address in Homework 1 would be reasonable questions.
8. Slide Deck 2:
Understand differences between C and Java
Compile time vs run time errors (e.g. static vs dynamic errors)
Do you know the 4 general categories of Computer Language statements?
Be comfortable with what the Preprocessor does; be able to describe it
Know what preprocessor directives are and their format
Be comfortable correctly using preprocessor directives like #define, #ifdef, #endif, #include
Of what does a C program consist?
Of what does a C function consist?
Be comfortable correctly declaring variables in C
know the difference between a declaration and a definition
be able to create a function prototype
understand the difference between pass by value vs pass by reference
File scope is first mentioned here.
From Slide 13: Be able to describe what functions the preprocessor, compiler, assembler
and link editor perform. You should be able to specify what files input to and output from
each of the steps. You should know the order in which they occur. This is the slide I
suggested you memorize.
You should know what the basic data types (e.g., know which are integer types and which
are float types) are and their relative sizes
Know how to create various derived types
Know how to define constants of various types. What are the defaults?
Know how to create symbolic constants
You should be able to recognize a C language keyword when you see it
Know correct conventions for naming variables (rules vs style)
9. Slide Deck 3:
Now that you’ve programmed in C a bit, I highly recommend going back through the slides in this
deck. You will be surprised at how much more understanding you will get with respect to data
representation. Doing so will likely help you on the midterm.
How is data represented in a computer?
Can you name several different ways to interpret data that is stored in a computer?
Converting from binary to hexadecimal or hexadecimal to binary
Converting from decimal to hexadecimal
Converting from binary/octal/hex to decimal
How many hex digits does it take to represent 1 byte?
How many binary digits (i.e., bits) does it take to represent 1 byte?
Logical Operators
Bitwise Operators
Bitwise shifting
Arithmetic Operators
Unary Operators
Know how to correctly use all C operators (the precedence chart will help)
Relational Operators
How does ANSI C deal with Boolean concepts?
Short‐circuit Evaluation
Can you correctly recognize a short‐circuit evaluation?
Can you correctly parse code that contains one?
Arithmetic type & expression casting – how C “helps” you (is it really help??)
What is the “promotion order” the C compiler uses to create equivalent types?
10. Slide Deck 4:
If you see the words L‐value or R‐value on the exam, will you know what that means?
Understand Precedence and Associativity as is applies to C code
Can you correctly parse something like this? d = ++a * c + b++;
Arithmetic Operators
Unary Operators
Do you know the difference between ++a and a++ ?
Know how to correctly use all C operators (the precedence chart will help)
Relational Operators
Go back through the Expression example. Could you correctly evaluate a similar on the
midterm?
Know what stdin, stdout and stderr are
Know how to redirect stdin, stdout and stderr, individually and collectively
What happens if you try to redirect stdin and the file you specify isn’t there?
What happens if you try to redirect stdout or stderr and the file you specify isn’t there?
What’s the difference between redirecting stdout/stderr with > versus >> ?
11. Slide Deck 5:
What is ASCII? What is EBCDIC?
C standard library functions for basic IO
When using scanf() or getchar(), from whence does our input come? How is data
represented when it comes in? Does it differ depending upon whether we use scanf() or
getchar()? What is the data type that is returned from each of these functions? What does
the value they return tell you?
When using printf() or putchar(), to where does our output go? How does our data have to
be passed to these two functions to display correctly? Does it differ depending upon
whether we use printf() or putchar()? What is the data type that is returned from each of
these functions? What does the value they return tell you?
Be able to correctly format scanf() and printf() statements
Be able to appropriately handle EOF as a return value from scanf() or getchar()
Be comfortable dealing with whitespace in your input when using scanf()
Consider “%[^\n]” and “ %[^\n]” . Are you comfortable with the difference between these
two scanf() format strings? What about “%s” and “ %s” ? Do you know what the extra space
does for you?
12. Slide Deck 6:
Know the 3 loop constructs and how to use them
Do you know how to embed an assignment statement within a conditional expression?
Be aware of one‐line loop bodies
Correct use of break and continue statements
Correct use of if, else‐if, switch‐case constructs
Correct use of comma operator and enumerated data types
be able to recognize a dangling else
Can you give a reason to write an infinite loop?
Can you correctly use a comma operator in a loop construct?
Can you correctly use a comma operator somewhere other than a loop construct?
If you aren’t sure, then you might want to determine if this little program gives you the
results you expect:
#include
int main(){
int a = (10, 5);
int b = 1;
int c = 10;
int d;
if (d = (b = a, a = ++b, c = b)) {
printf(“Writing a test program is sometimes the only way to be sure.\n”);
}
printf(“a=%d, b=%d, c=%d, d=%d\n”, a, b, c, d);
}
If you saw an enumerated data type declaration and then code that used it, would you know
what the code was doing?
13. Slide Deck 7:
Know how to create a makefile, create dependencies, and be able to explain why one might
want to use a makefile
Did you watch this video?
Expect to miss at least one question on the exam if you didn’t.
Be able to create a makefile if you have a “model” to go by
What Unix/Linux command uses a makefile?
Is compile programs the only thing we can do with a Makefile?
14. Slide Deck 8:
Know the difference between variables, addresses of variables and contents(values) in
memory
Review pointers, the dereference operator (*) and the address operator (&) along with
correct use of each
Know how to correctly declare pointers, multiple pointers on one line, and pointer to
pointers (to pointers, etc.)
Be comfortable reading, writing and manipulating data using (*) and (&)
How many bytes does a pointer get allocated when using a 64‐bit processor?
Review pointer casting
Be able to answer a question like the Carmen exercise we did with pointers
If main() has a block scope variable declared int *array1, and main() calls functionA() and
funcitonA() calls functionB(), then what is the least complex way to allow functionB() to
access the memory location where the variable array1 is stored? (i.e. what should main()
pass to functionA() and what should functionA() pass to function()?
15. Slide Deck 9:
Be able to explain the differences between statically and dynamically allocated arrays
Be able to correctly use the name of a statically allocated array as a pointer
Be able to create statically and dynamically allocated memory
Be able to initialize statically allocated arrays during declaration
Know where dynamically allocated memory is located
Be able to write C code the uses both types of arrays
Copying arrays
Review (void *) and when it is used
Review malloc(), calloc(), and free()
What are 3 most frequent errors when working with dynamic memory?
Be comfortable working with pointer arithmetic and arrays(dynamic & static) and the
dereference operator
Know the difference between *(ptr+1) and *ptr + 1
The differences of passing parameters by value vs passing parameters by reference. What
might be the results of each within the calling function?
Be able to recognize a multiple level of indirection data configuration if you see one.
Obviously, you should be able to answer questions about such a configuration because you
created one in lab 3.
Know when using the function perror() is appropriate (and when it’s not).
16. Slide Deck 10:
Know the difference between string literals (read‐only strings) and strings which are arrays
of characters (read‐write strings)
Remember that strings must be NULL terminated and that scanf() will do so for you when
reading in strings….getchar() will not
If you statically declare a string of size 50 (e.g. char string1[50] = “String Length”; ), then we
have populated it with a string of length 13. What do you know about the values stored at:
a. string1 indexes 0‐12?
b. string1[13]?
c. string1 indexes 14‐49?
Know how to use pointers when working with strings
Know when a char * should be declared vs when a char array should be declared as it relates
to strings
Know where string data is stored based upon how it is declared (i.e. stack, heap, read‐only
memory)
Know how to access individual characters within a string
Be able to use scanf() and printf() to read in and print out strings
Be able to use pointer arithmetic with strings
Review
Character Classification Functions
Character Modification Functions
String Library Functions
17. Slide Deck 11:
Be able to declare a structure
Understand the concepts/properties of two structures declared similarly, but independently
(e.g. slide 6)
Understand the difference between a typedef, tag, and name of the structure variable
Understand when to access structure members with the dot operator (.) versus when to
access them with the arrow (‐>) operator.
Review how to pass a structure as an argument to a function
left‐operand‐>right‐operand is equivalent to (*left‐operand).right‐operand
Do you know how to initialize a structure within a declaration?
What does the keyword const do for us when passing pointers to an array or structure as a
parameter?
18. Slide Deck 12:
Be able to construct a linked list with C programming statements.
Know how to declare and dynamically allocate the appropriate memory for nodes
Know how to write create(), insert(), delete() functions
Know how to build a linked list
Be able to describe how to sort nodes into some type of order
Know how to appropriately pass the list_head pointer into functions based on the operation
the function is to perform (i.e. pass by reference or by value and how to code it)
Can you create an integer key using year/month/day?
Know how to free your dynamically allocated nodes at the termination of your program.
19. Slide Deck 13:
Be comfortable with Big Endian vs Little Endian and how each stores data in memory
Know the differences between structures and unions
Can you print numbers with printf() that have a comma after every 3 digits?
Be able to correctly use fopen(), fprintf(), fscanf() and fclose() to work with I/O to or from a
file
Byte boundary alignment is first mentioned here
20. Slide Deck 14 :
Know how arguments are passed to main() from the command line
Know how to use argc and argv[] to access the arguments from the command line
Know what is contained within each argv[] vector
proper use of the contents of argv[0]
can you appropriately convert ASCII strings to other data types?
The two command line arguments in lab 4 were both ASCII strings representing filenames.
Keep in mind that not all command line arguments can be used as ASCII strings.
21. Slide Deck 15:
Be able to declare a pointer to a function and an array of pointers to functions
Be able to initialize a function pointer or an array of function pointers
Be able to call a function with a function pointer
22. Slide Deck 16:
Be able to explain the differences between storage class, scope, and linkage and what
different storage locations are available
Know how to declare variables for appropriate class, scope, and linkage specifications
Be able to identify a variable’s storage class, scope and linkage
Correct terms (e.g. static, block, external, prototype) are required when discussing these
concepts
Can you specify class/scope/linkage of a variable within a section of code?
If you did well on the 3 exercises on this topic you should be in good shape.