Data Type, Variable(2)(2)
Data Type, Variable(2)(2)
Variables
Assignment Operator
Arithmetic Operators
+ 7
4
In most computer programs, we need data storage to represent and store data temporarily.
Name Value
priceOfChickenRice = 2.8
priceOfChickenRice 2.8
• combination of values (e.g., literal, variables, etc.) and operations (e.g., operators, functions, etc.)
Examples
• 3.14
• 100*15
• Result *100
The ‘=‘ sign is the assignment operator, not the equality in mathematics.
Basic Syntax
a variable an expression
Assignment means:
2. Take the resulting value and assign it to the name (variable) on the LHS.
• can be negative {–1, –2, –3, – 4, – 5, …}, positive {1, 2, 3, 4, 5, …}, or zero {0}
Integers
–5 –4 –3 –2 –1 0 1 2 3 4 5
Whole Numbers
Floats Represent real numbers; allow fractions (e.g., 2.8, 7.1, 9.0001)
• Each arithmetic operator is a mathematical function that takes one/ two operand(s) and
performs a calculation on them
• Most computer languages contain a set of such operators that can be used within
equations to perform a number of types of sequential calculation
Flowchart
start
Read horizonDist
Read vertDist
3
dist = horizonDist + vertDist
end
Nilsson S. (2014). Cup of coffee [Online Image]. Retrieved April 17, 2018 from
3 7, 9
https://www.flickr.com/photos/infomastern/14956851150.