COVERAGE
Lecture notes: all
Text: Chapters 1, 2 and Sections 3.1-3.9 of Chapter 3
SUMMMARY OF IMPORTANT TOPICS YOU SHOULD KNOW AT THIS POINT
COMPUTERS & PROGRAMMINGING LANGUAGES
Computer: input unit, output unit, memory unit, ALU, CPU, secondary storage unit
Programming language: machine language, assembly language, high-level language
Structured programming language
Object-oriented programming language
C++ is both a structured and object-oriented programming language
PLATFORM: MS VISUAL C++ INTEGRATED DEVELOPMENT ENVIROMENT (IDE)
Editor
Compiler
Linker
Execution
Source code (stored in file with extension .cpp)
Object code
Executable code
BUGS
Syntax errors
Run-time errors
Logical errors
DESIGNING YOUR PROGRAM
Top-down design (stepwise refinement)
Algorithm
Programmer's Algorithm:
1. Define problem
2. Plan the problem solution using top-down design
3. Code the program
4. Test and debug the program
5. Document the program
Recommendation: Design your program in stages. At each stage you should have a working program. Don't include all the details (bells and whistles) in your initial program, but instead at each stage add on a few features and debug. It is a good idea to keep each of the development stages of your program in separate files, so you can go back to an earlier version if need be.
GOOD PROGRAMMING STYLE
Comments
User-friendly prompts
Descriptive variable names
Proper indentation
etc.
C++ PROGRAM
Comments
Preprocessor
Preprocessor directive #include
Header file
Organization of a
C++ program: Preprocessor section, Main function section
Output:
cout, escape sequences, e.g., \n
Input: cin
DATA CLASSES
Class
Object
ADT (Abstract Data Type)
Standard Data Classes
1. Integer class: short, int, unsigned int, long, unsigned long
2. Floating point class: float, double, long double
3. Character class: char, unsigned char, ASCII
4. Character string class
5. Boolean class
CONSTANT AND VARIABLE OBJECTS
Defining (declaring) constant objects
Defining (declaring) variable objects
OPERATIONS ON STANDARD CLASSES
Arithmetic operations: +, -, *, /, %
Integer operations vs. floating point operations
Example: Computing average
Order of precedence
Increment and decrement Operators: ++, --
Assignment operators: =, +=, *=, etc.
Boolean relational operators: ==, !=, <, <=, >, <=
Logical operators: !, ||, &&
Truth Tables
CONTROL STRUCTURES
1. sequential
2. selection
MODULAR PROGRAMMING & FUNCTIONS