Module G51PR1 Semester 1 1997/98; Rough lecture plan Ceilidh course "pr1" : Introduction to C++ programming (Steve Benford). This course is aimed at the complete novice to programming, and teaches the first essentials if the C++ language. The course can be taken on its own, but Ceilidh supports two further C++ courses which describe the object-oriented approach to program design in C++. In particular, the "pr2" course entitled "Programming in the large" describes features which enable C++ to be used on larger projects. At the completion of this "pr1" course, the student should know the basic concepts of C++ for use when a program consists of a single module. You should be fluent in writing simple programs. The course is divided into 10 units (the given numbers of lectures are approximate). Unit 1 : Introduction (2 lectures) 1.1. High level languages 1.2. Compilation versus interpretation 1.3. A brief history of C++ 1.4. A minimal C++ program 1.5. Creating, compiling and running your program 1.5.1. Creating the program 1.5.2. Compilation 1.5.3. Running the program 1.6. The Ceilidh system 1.7. General Unit 2 : Elementary programming (2 lectures) 2.1. A simple program 2.2. Output from the program 2.3. Constants and variables 2.4. Basic types 2.5. Denotations 2.6. Comments 2.7. Program layout 2.8. Input to the program 2.9. Operators in more detail 2.9.1. Arithmetic operators 2.9.2. Comparison operators 2.9.3. Logical operators 2.9.4. Incremental operators 2.9.5. Assignment 2.9.6. The comma operator 2.9.7. Operator precedence Unit 3 : Conditionals (1 lecture) 3.1. If statements 3.1.1. Simple "if" statements 3.1.2. "If ... else ..." statements 3.1.3. Further alternatives 3.1.4. Possible conditions (logical expressions) 3.1.5. The comma operator 3.1.6. Nesting "if" statements 3.1.7. Ambiguity 3.2. Switch statements 3.2.1. Switch example 3.2.2. Character switch example 3.2.3. Notes Unit 4 : Loops (3 lectures) 4.1. "while" loops 4.2. "do" loops 4.3. "for" loops 4.4. General points on loops 4.4.1. Nesting of loops 4.4.2. The "break" statement 4.4.3. The "continue" statement 4.4.4. Example of "break" and "continue" 4.4.5. Comments 4.4.6. Curly braces 4.4.7. Empty loop bodies 4.5. Other general loop examples 4.5.1. Sum, minimum, and maximum of data 4.5.2. Sum of squares 4.5.3. Decreasing powers of 2 4.5.4. Read a sentence of text 4.5.5. Increasing and decreasing integers Unit 5 : Functions (3 lectures) 5.1. Motivation: the need for functions. 5.2. A simple example of a function 5.3. Declaration versus definition 5.3.1. The function declaration 5.3.2. The function definition 5.4. Returned types 5.5. Parameter types 5.6. Default parameters 5.7. Function overloading 5.8. Program structure 5.9. Local variables 5.10. Parameters called by value 5.11. Jargon reminder 5.12. A complete example 5.13. Examples 5.13.1. Circle radii and areas 5.13.2. Summation 5.13.3. The OK function Unit 6 : Miscellany (1 lecture) 6.1. Program layout 6.2. Basic types 6.3. Lazy programming 6.4. Lazy operators 6.5. Bit-wise operators (keenies only) 6.6. Declarations 6.7. Goto's and assignments considered harmful 6.8. Error output 6.9. Strings 6.10. The "system" function 6.11. File inclusion 6.12. Formatted output Unit 7 : Arrays and structures (6 lectures) 7.1. Arrays 7.1.1. Examples of the requirement for arrays 7.1.2. Declaration of arrays 7.1.3. Calls of array elements 7.1.4. Other array examples 7.1.5. Array elements and indexes 7.1.6. Searching for words 7.1.7. Initialised arrays 7.1.8. Two-dimensional arrays 7.1.9. Higher dimensional arrays 7.2. More array examples 7.2.1. Reflect lines 7.2.2. Arrays as function parameters 7.3. Structures 7.3.1. Examples of the requirement for structures 7.3.2. Declarations of structure types 7.3.3. Declaration of structure objects 7.3.4. Accessing elements of a structure 7.3.5. Initialising structures 7.3.6. Bit-fields in structures (keenies only) 7.3.7. The use of arrays of structures Unit 8 : File input/output (1 lecture) 8.1. Introduction 8.2. The basics of file access 8.3. Files in C++ 8.4. The use of files in general Unit 9: Miscellany 2 (1 lecture) 9.1. Reading characters 9.2. Arrays of strings Unit 10: Pointers (Not taught here) 10.1. Simple pointers 10.1.1. Pointers and arrays 10.1.2. Pointers for loops 10.1.3. Priorities 10.2. Double pointers (pointers to pointers)