C++_Lecture_Two
C++_Lecture_Two
Programming Fundamentals
◼ Data types
◼ Variables and Identifiers
◼ Arithmetic and Logical Expressions
NOTES:
◼ Some programming languages are case
sensitive. That is the uppercase identifiers are
different than lowercase identifiers (as in C++).
◼ main
◼ if
◼ else
◼ switch
◼ while
◼ do
◼ for, ………….
◼ Variables:
-The name of the location is the variable name.
-The location content is the value of the variable
- You can change the content of the variable at any
time in the statements of the algorithm.
e.g.
Name of the location Inside Memory location
employee_name “Ali Ahmed”
age 35
hourly_rate 3.25
EX:
where A, B are defined logical
EX:
◼ Precedence Rule:
- Each operator has its own precedence that
indicates the order of evaluation.
- If the expression has operators of the same
precedence, then the evaluation starts from
left of expression to the right.
( ( parentheses Higher
*, /, MOD *, /, %
+, - +, - Binary plus, binary
minus
<, , ≤, >, ≥ <, <=, >, >=
=,≠ == , != Equal, not equal
AND &&
OR ||
= Assignment Lower
Programming Fundamentals (Lecture Two) 18
Examples
16
(2) (9 + 3) - 6 / 2 + 5
12
(2) OR table
OR True False
True True True
False True False
x AND y OR z
False