Lecture 1
Lecture 1
programming
1.1 Computer systems
• Computer
• hardware : actual physical machines
• Software : collection of programs used by a computer
• Program : set of instructions for a computer to follow
Computer systems …
• Bit : a digit that can only be zero or one
• Bytes :
• eight binary digits or bits
• computer’s main memory is divided into a series of numbered locations
• Address of the byte :
• the number associated with one of these bytes
• Often these bytes are grouped to form a larger memory location.
• address of first byte is used as address of the larger memory location
Computer systems …
• The program and the data are input to the computer via the operating system.
Types of computer languages
1) Machine Language (ML)
- The only language computers directly understand
- Machine – dependent
- clearer to humans
- incomprehensible to computers
- ADD
- STORE
- LOAD
Types of computer languages …
3 . High- level Language (HLL)
- similar to everyday English and use common mathematical notations
- incomprehensible to computers
- C++
- Java
- Python … etc
Compiler and linker
• e.g. combining your object code with input and output routines that your program uses
perform a computation.
• Output is an algorithm
• Implementation Phase
• Encapsulation:
• Inheritance
• Making a code reusable again for objects having the same behavior and properties.
• Polymorphism
3. Implementation (coding)
4. Testing
6. Obsolescence
Introduction to c++
• Bjarne Stroustrup of AT&T Bell Laboratories developed C++ in the early 1980s.
• Most of C is a subset of C++, and so most C programs are also C++ programs.
-It tells the compiler where to find information about certain items that are used in your program.
#include <iostream>
-iostream is the name of a library that contains the definitions of the routines that handle input from the keyboard
-The linker program combines the object code for the library iostream and the object code for the program you write.
A sample c++ program ….
#using namespace std;
-the names defined in iostream are to be interpreted in the “standard way”
-std is an abbreviation of standard
int main( ){ }
-Specifies that the program starts executing here.
-The curly brace shows the start and end of the body of the main part.
return 0;
-It is called a return statement.
-It tells the program to end the execution.
A sample c++ program
Testing and debugging
• A Bug: a mistake in a program.
• Syntax Errors
• The compiler tells you that your program contains a syntax error.
• Runtime Errors
• Errors that are detected by the computer when the program runs.
• Logical Errors
• A mistake made by a programmer during the development.
• To avoid logical errors programming carefully and testing the program with different
data sets is preferable.