Programming in C++ Programming in C++ Programming in C++ Programming in C++
Programming in C++ Programming in C++ Programming in C++ Programming in C++
Dr. M. Ahmadzadeh
Lecture 2
Computers…
• History
– 50s:
• big computers
• used by a limited number of people
– 60s:
• Multi million dollars computers
• Used by big company and a specialist
person
– 70s:
• Smaller in size and faster in process
• Used by ordinary people
– 90s:
• Even smaller in size and faster in
process
• Used by people in all aspect of life
Computers…
• Hardware
– Input
• Keyboard, scanner, hard disk , memory
etc.
– Output
• Screen, printer, hard disk, etc.
– Storage
• Volatile: memory
• Non-volatile: hard disk, floppy disk, CD,
flash memory, etc.
– Process
• CPU
– CU
– ALU
Computers…
• Software
– Is written by programming languages
• Machine Language: sequence of 0 and 1
• Assembly Language, needs assembler
• Mid-level and high-level languages, need
compiler or interpreter
– has two types:
• System program: to control the system
– Operating system
– Linkers
– Loaders
• Application program
– Word Processors, Spread Sheets
– Games
– And of course the programs that you are
going to write in this module.
A program in C++
# include <iostream.h>
int main(){
cout<< "This Is My First"<<"\t";
cout<< "C++ P R O G R A M."<<"\t";
cout<< "Hooray!"<<"\n";
return 0;
}
• Some tips
•Whenever you opened a brace, you need indentation
for next instruction
• your program needs at least one header
How to run this program
• Load Microsoft Visual C++
• Write the code
– File New Workspace tab Blank
Workspace
– File New Files tab C++ Source File
• Compile it
• Build Compile
• If it has compiler error, correct your
program
• Execute it
– Build Execute
• It is environment-independent.
Flowchart
• A graphical representation of
a psuedocode
• Different boxes have different
meanings.
– Circle
– Rectangle
– Lozenge
– Parralelogram
Exercise
• Calculate the area and
perimeter of a rectangle using
pseudocode and flowchart