BITP 1113 Programming Technique: Lecture 3 - Basic Elements of C++
BITP 1113 Programming Technique: Lecture 3 - Basic Elements of C++
int item;
Variable Definition
20 is an integer literal
itemsOrdered
totalSales Yes
total_Sales Yes
itemsOrdered = 15;
Integer Literals
CODE: MEMORY:
char letter; letter
letter = 'C';
67
'A'
H e l l o \0
allDone finished
1 0
item = 12;
// ERROR!
12 = item;
int height;
cout << "How tall is the room? ";
cin >> height;
- subtraction ans = 7 - 3; 4
* multiplication ans = 7 * 3; 21
/ division ans = 7 / 3; 2
% modulus ans = 7 % 3; 1
evaluate
evaluate evaluate third
second first
y 2 y1
m
x 2 x1
sum = sum + 1;
Continued…
69 FTMK - UTeM - Semester 1 2011/2012
Increment and Decrement
Operators in Program 5-1
Continued…
78 FTMK - UTeM - Semester 1 2011/2012
The setw Stream Manipulator in Program 3-13
Continued…
81 FTMK - UTeM - Semester 1 2011/2012
More Stream Manipulators in Program 3-17