Professional Documents
Culture Documents
Course Pre-Requisite
Basic Computing & Programming
Text Book
Dietel & Dietel, C++ How to program.
Reference Book
Robert Lafore, Object Oriented Programming in C++
Grading Criteria
Mid term Final term Sessional 25% 50% 25%
Contents of Week 1
What is a Computer and what are computer languages Machine languages, Assembly languages and High level languages Translators: Compilers, Interpreter, Assembler History of C and C++ C++ Standard Library Structured Programming Basic of a Typical C++ Environment Algorithms, Pseudocode
What is a Computer?
Electronic device that receives, stores, retrieves and process information Device capable of performing computations and making logical decisions.
consist of: Software
Instructions to command computer to perform actions and make decisions. (Programs that run on computer).
Hardware
Various devices comprising computer
Keyboard, screen, mouse, disks, memory, CD-ROM, processing units,
Computer languages
Defines the rules under which programs are written to make use of computers Machine languages Assembly languages High level languages
Computer Languages
Machine language
Only language computer directly understands Defined by hardware design
Machine-dependent Ultimately 0s and 1s
Computer Languages
Assembly language
English-like abbreviations representing elementary computer operations Clearer to humans Incomprehensible to computers
Translator programs (assemblers) Convert to machine language
Example:
LOAD BASEPAY ADD OVERPAY STORE GROSSPAY
8
Computer Languages
High-level languages
Similar to everyday English, use common mathematical notations Single statements accomplish substantial tasks
Assembly language requires many instructions to accomplish simple tasks
Interpreter programs
Directly execute high-level language programs
Example:
grossPay = basePay + overTimePay
9
10
C and C++
C is a high level language designed to be,
Much easier to understand than assembler As powerful As fast Close to the machine portable
Compile each source file Link with other compiled source files and libraries Now can execute our program C++ is easy, learning how to use the libraries is harder!
Structured Programming
Disciplined approach to writing programs Clear, easy to test and debug and easy to modify
1. Edit
2. Preprocess
the editor and stored on disk. Preprocessor program processes the code. Compiler creates object code and stores it on disk. Linker links the object code with the libraries
3. Compile
4. Link
Loader Disk
5. Load
6. Execute
Primary Memory
CPU
15
. . . . . .
CPU takes each instruction and executes it, possibly storing new data values as the program executes.
cout
Standard output stream Normally computer screen
cerr
Standard error stream Display error messages
16