Lecture 02
Lecture 02
Lecture 2
Aamina Batool
Identifier
Examples:
-6728
0
78
bool type
C++ Operators
+ addition
- subtraction
* multiplication
/ division
% remainder (mod operator)
+, -, *, and / can be used with integral and floating-
point data types
Order of Precedence
Arithmetic Operators (+ , -, /, %, *, =)
Relational Operators ( < , > , =, <=, >=, ==)
Pseudocode
Example:
IF (student is part_time)
Add one to part_time_count
ELSE
Add one to full_time_count
Write pseudo code that reads two numbers and multiplies them
together and print out their product.
Write pseudo code that tells a user that the number they entered is
not a 5 or a 6.
Solution # 1:
Declare num
Input num
If(num = 5)
Print “your number is 5”
Else if (num = 6)
Print “your number is 6”
Else
Print “your number is not 5 or 6”
Examples
Solution # 2:
Input num
If(num = 5 or num = 6)
Print “your number is a 5 or a 6”
Else
Print “your number is not 5 or 6”
Examples
Solution # 3:
Input num
If(num is not 5 and num is not 6)
Print “your number is not 5 or 6”
Else
Print “your number is a 5 or a 6”
References