AMAT-2120 Midterm Topics
In answering test questions,
you will be responsible only for material explicitly covered in class.
Reference to book sections and pages below are given for your convenience.
You can use methods and language elements not
discussed in class, but it will not be necessary.
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 setting bounds of admissible data,
exact form of output, a manner of program's communication
with user etc.
-
General:
-
Hardware vs Software.
-
Basics of computer operation. CPU vs Memory vs Peripheral devices.
-
Operating system and Low level utilities (console shell, window manager) vs
Application programs.
-
Notions of algorithm, computer program (Sect.1.1), translation/compilation
(p.10), syntax (p.15).
-
Units of information: bit, byte (Sect.2.8).
-
General understanding of how computers store numbers and characters.
Binary, octal, and hexadecimal values (practical conversion to/from
base 10 and between; cf. Ex.9 on p.59).
ASCII codes (principle; - don't memorize).
-
Elements of the UNIX system:
-
Files and directories. Directory tree. Root dir. ('/'), current dir
(' . '),
parent (upper level) dir. ('. .'), subdirectories.
Absolute and relative path.
Case-sensitivity of file and dir names.
-
Notions of algorithm, computer program (Sect.1.1), translation/compilation
(p.10), syntax (p.15).
-
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 and variables: types int,
float, double, char.
Operator sizeof (p.75).
-
#include - statement. Two versions of syntax: (a) for C library files
(e.g. <stdio.h>); (b) for programmer's files ("myfunc.h").
(Optionally: Other preprocessor directives - #define, #ifdef/#else/#endif
-- see Lab.5 and p.112-114).
-
printf operator.
Format specifiers (%d, %f, %c: p.48;
%o, %x: p.54; %s (for strings): 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.
(Notes; also p.88).
-
C's treatment of boolean values as integers (p.125, also p.132).
Logical operators: AND (&&), OR (||), NOT (!).
-
Bitwise AND (&) and OR (|) (p.459-461+). Optionally: other
bitwise operators: XOR(^), NOT (~), shifts (>>, <<).
-
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).
-
Loops: for (p.184), while (p.163), their functional
equivalence (see notes or pp.185,194) and flow charts.
Distinction from do-loop (p.198).
-
Variable address vs Variable contents (Fig.3.3). Addresses and pointers.
Declaration of pointers. (Sect.3.2)
-
Passing arguments to/from functions: by value and by reference
(in the latter case: '&' symbol on caller's side vs '*' in function's
header). (Sect.6.5)
-
Input with scanf function. Syntax (format, &).
Necessary preceding prompt with printf (pp.100-104).
-
Programmer-defined functions (Sect.6.1). Prototype vs Definition.
Header, use of semicolon. Special cases: empty parameter list;
void return "type".
-
Static arrays (Sect.7.1). Bounds of index: [0,size-1].
Initialization using a loop (p.280).
-
Arrays as pointers (Sect.8.1). Dynamic memory allocation:
malloc function (p.402).
-
Character strings: Representation in memory (Fig.9.1);
NULL character. Length of string is one less than Size of representing array
(cf. description of strlen function on bottom of p.356).
Loop for string processing relying on the NULL character
as the termination condition (Example: string copy program -- notes or
p.344).
-
Command-line arguments of a program and
corresponding arguments of main function.
Argument count. (Sect.12.4, esp. Program 12.4 on p.472).
Converting a string to an integer with
atoi functions (p.623, <stdlib.h>, line 4).
-
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 (par.1,2 on p.261 optional), 7.5, 8.4 (as much as you can handle),
9.5.
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 non-obvious precedence,
explicit casts (cf.p.456),
using decimal dot in fl.pt.constants even such as '0.0'.
-
Using modular design to keep functions short.
-
Naming conventions for multi-word variables and functions (myFunc,
my_func),
and for pointer variables (x_ptr).
-
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).