Exam 2.1 and 2.2 (CMSC216 Spring 2020)
General Information
- Date (Exam 2.1): Thursday April 16
- Time:
- 11:40 am - 12:15 pm (for 010x and 030x
sections)
-
12:30 pm - 1:05 pm (for 020x sections)
- Duration: 35 minutes
- Date (Exam 2.2): Tuesday April 21
- Time (limited to 70 mins):
- 11:00 am - 12:15 pm (for 010x and 030x
sections)
-
12:30 pm - 1:45 pm (for 020x sections)
- Additional details (e.g., Zoom meeting links) will be
announced in
Piazza
- Open-book, open-notes
- But, you are NOT allowed to use
Internet (e.g., search),
to access grace, or to run code
locally. These are academic integrity violations.
- The best way to prepare for the exam is to practice old exams. Complete
several
of them in the allocated time specified in the exam.
- After you have taken the exam, do not discuss
anything associated with the exam with other students that might not
have
taken the exam yet.
- Posting any information in Piazza about the exam after taking it
is considered an academic integrity violation.
Exam Structure
- Short answer questions: This includes for example, multiple
choice, true/false, and fill-in-the-blank type questions.
- Code analysis questions: We will give a short segment of code and
you may be asked to identify syntax and logical errors, generate code
output, etc.
- Code Writing: Write a program/code snippets to solve a given
problem. You should be prepared to give a complete program, but we may
also
ask you to provide just a single function or a code fragment.
Topics
The exam will include all the material covered in discussion session (lab),
lecture, quizzes, exercises, and projects including the
following topics:
- Unix - You must be familiar with the following commands.
- cp
- ls
- cd
- pwd
- gcc
- rm
- mv
- diff
- rmdir
- rm -r
- How to use grep to find patterns in a file
- How to change file / directory permissions (e.g., chmod 700 file)
- C Language
- Preprocessor directives (e.g., #include, #define, #ifdef)
- Expressions
- Bitwise Operators. Some sample questions can be found at BitwiseOpWorksheet.pdf.
- Conditional statements
- Loops
- Arrays (one and two dimensional arrays)
- Strings - You are responsible for the following string functions.
- strlen
- strcpy
- strcmp
- strcat
- memcpy
- memmove
- Pointers (including function pointers)
- enum
- Structures
- Unions
- Functions
- stdin, stderr, stdout
- Linkage
- Command line arguments
- exit
- err
- perror
- Dynamic Memory Allocation (malloc, realloc, free, etc.) (not
for Exam
2.1)
- Data Representation, including:
- How characters, integers (positive and negative) and floats
are represented.
- The 2's complement representation of a number
(representation of signed integers).
- Understand the imprecision associated with real numbers.
- Why casting a variable is not the same as getting its address,
casting to a type and dereferencing.
The casting.c example in Data-Rep-Code provides an example.
- No need to know how to generate the binary representation
for a float value using the IEEE 754 standard;
just understand that some bits represent the mantissa,
some bits the exponent and the left most bit the sign.
- Big Endian vs Little Endian.
- Reading and writing from files.
- Memory maps - Please use the style provided in the following
example MemoryMapExample.pdf. Previous
exam solutions consider as correct using a pointer to the first array
element in order
to describe an array; that is not correct. See the diagram we have
provided.
- Linked Lists (both singly and doubly linked lists) (not for Exam
2.1)
- Recursion
- Makefiles - You need to know how to define makefiles without using
implicit rules. The following is an example of the kind of
makefile we expect
you to write in the exam: makefile_example.
You may not use wildcards (except *).
The exam will NOT cover the following topics:
- Assembly, fork, exec*, dup2, pipes, emacs, arduino, debugger, splint,
valgrind, -fmudflapth -lmudflap
Suggestions
-
Instead of
if (ptr != NULL) {
}
use
if (ptr) {
}
-
When you have nested structures defining a pointer to a field can help.
/* Using a pointer to simplify handling structure fields */
printf("Section number is %d\n", all_courses[1].section1.section_number);
printf("Section number is %d\n", all_courses[1].section1.num_students);
/* Equivalent to previous two statements */
ptr = &all_courses[1].section1;
printf("Section number is %d\n", ptr->section_number);
printf("Number of students %d\n", ptr->num_students);
-
Instead of
if (strcmp(a, b) == 0) {
}
use
if (!strcmp(a, b)) {
}
-
Instead of
while (*p != '\0') {
}
use
while (*p) {
}
- Regarding linked lists
Practice Material
Practice material is available in Grace under
216public/exams/exam2;
ignore the parts outside the topics of this exam (eg, assembly, process
control).
To transfer this material to your computer,
use https://dav.terpconnect.umd.edu.
Use your directory id/passwd (same one used for grace) to log on.