AMAT-2120 Midterm Material
In answering test questions,
you will be responsible only for material explicitly covered in
class.
Notes, Labs, and Assignments give the most precise idea about the
scope of material.
Reference to book sections and pages below are given for your convenience.
Practical working knowledge rather than verbal definitions is a priority.
You are allowed to use language elements mentioned as optional
or not mentioned at all in class, but I ask you not to use
C++ style syntax if you know some of it.
In the programming question, a hint will be given regarding the
mathematical algorithm. It will be entirely up to you to
implement it in a C program as well as to make design decisions
like determining
exact form of output, a way of program's communication
with user, treatment of special cases, etc.
-
General:
-
Hardware vs Software.
-
Basics of computer operation. CPU vs Memory vs I/0 devices.
-
Operating system, window manager
console shell vs
Application programs (editor, compiler, etc.) -- knowing
difference in practice.
-
Notions of algorithm, computer program (Sect.1.1), translation/compilation
(p.10), syntax (p.15), flow chart (p.9) -- we need only
rectangles and rhombs.
-
Units of information: bit, byte (Sect.2.8).
-
General understanding of how computers store numbers.
Binary values (practical conversion from decimal to binary
and back; cf. Ex.9 on p.59).
-
Elements of the UNIX system:
-
Files and directories. Directory tree.
User's home directory; system's root dir. ('/');
current dir(' . '),
parent (upper level) dir. ('. .'), subdirectories.
Absolute and relative paths.
Case-sensitivity of file and directory names.
-
Command-line interface of console programs.
Arguments of a program.
Special meaning of the '&' character at the end of command.
-
How to create a file from scratch: cat command; editors.
Automatically generated files (a.out).
-
Frequently used shell commands:
whoami, pwd, cd, ls and ls -l (full info),
mkdir, rmdir, cp, mv, rm,
chmod, script.
-
Elements of the C language:
-
Structure of main function (Fig.1.14).
Declarations (definitions) vs executable statements.
-
Comments.
-
Data types: int,
float, double, char.
Operator sizeof (p.75).
-
Preprocessor directives:
#include (most important); #define <symb.name>,
#ifdef/#else/#endif
(Lab 4; pp.112-114).
-
Command line option -lm used with math.h
library
-
printf operator.
Format specifiers (%d, %f, %c: p.48;
%s (for strings): Lab 1 and p.343). Special character
'\n'.
Optionally:
format modifiers (p.52), other special characters (p.41).
-
Basic arithmetic. Precedence rules. (Sect. 2.2)
Assignment operators (sect. 3.1). Shorthand forms (+= etc.)
Difference between prefix (i++) and postfix (++i) forms.
(p.88).
-
C's treatment of boolean values as integers (p.125, also p.132).
Logical operators: AND (&&), OR (||), NOT (!).
-
Relational (comparison) operators (p.124): >, <, etc.
Difference between the "equal to" operator == and the assignment
operator =.
-
if-else construction. Use of braces and semicolon. Single and
compound statements. Nested if (4.3); if with
no else
-
``for'' loop (p.184); three components of the header.
Flow chart.
-
Other loops:
while (p.163), do (p.198); functionally
equivalent for loops (see notes or pp.185,194).
Distinct feature of do-loop: runs the body at
least one time.
-
Some standard functions of math.h library
(see Labs and Assignments; also p.622)
-
Input with scanf function. Syntax (format, &).
Necessity of preceding prompt with printf (pp.100-104).
-
Programmer-defined functions returning one value or no values
(Sect.6.1).
Prototype (declaration) vs Implementation (definition).
Header, use of semicolon. Special cases: empty parameter list;
void return "type".
Formal and actual parameters. Should their names be same?
-
Skills in code tracing by hand, including code with branching,
loops and function calls.
-
Common programming errors. Besides recalling own experience,
review Sections 1.6, 2.6, 3.6 (items 8,9 optional),
4.5, 5.5 (ignore mention of switch; item 2 optional),
6.6.
The best way to study errors is to try them on purpose and
watch the effect.
-
Elements of Programming Style.
-
Header of program. Relevance of comments.
-
Enhancing readability of code:
line breaks, indentation (p.25), placement of braces (p.135),
brackets when precedence is non-obvious, short math operations
(break into steps),
explicit casts (p.456),
using decimal dot in floating point constants e.g. '0.0'.
-
Using modular design (functions)
for the sake of development speed and minimal size of code.
-
Standard naming convention for one-character identifiers
(i,j,k,l,m,n for int etc.); meaningful names
of variables and functions.
-
Consistence in adopted style.
-
User-friendliness of program (Prints its purpose?
Shows prompt for input? Treats invalid input?)
-
Debugging style: intermediate outputs, function stubs
(p.223-224), sample data (using small numbers, cf. Q1 in Asst.2).