Topic 4 Expressions and Variables
Topic 4 Expressions and Variables
"Once a person has understood the way variables are used in programming, they have understood the quintessence of programming."
-Professor Edsger W. Dijkstra
Based on slides bu Marty Stepp and Stuart Reges from
Data and expressions
reading: 2.1
2
The computer's view
Internally, most computers store everything as 1's and 0's
? Example:
h
01101000
"hi" 0110100001101001
104 01101000
How can the computer tell the difference between an h and 104?
type: A category or set of data values.
? Constrains the operations that can be performed on data ? Many languages ask the programmer to specify types ? Examples: integer, real number, string
Binary Numbers
3
Java's primitive types
primitive types: 8 simple types for numbers, characters, etc.
? Java also has object types, which we'll talk about later
Name
? int ? double ? char ? boolean
Description
Examples
integers
(up to 231 - 1) 42, -3, 0, 926394
real numbers (up to 10308) 3.1, -0.25, 9.4e3
single text characters
'a', 'X', '?', '\n'
logical values
true, false
? Why does Java distinguish integers vs. real numbers?
4
Integer or real number?
Which category is more appropriate?
integer (int)
real number (double)
1. Temperature in degrees Celsius 7. Number of miles traveled
2. The population of lemmings
8. Number of dry days in the past month
3. Your grade point average
9. Your locker number
4. A person's age in years
10. Number of seconds left in a game
5. A person's weight in pounds
11. The sum of a group of integers
6. A person's height in meters
12. The average of a group of integers
credit: Kate Deibel,
5
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- question 1 what is the value of the following expression
- topic 4 expressions and variables
- unit iii compiler design scs1303
- infix and postfix expressions1 stonehill college
- kendriya vidyalaya panchgram
- chapter iii boolean algebra
- evaluate expressions play answer sheet
- evaluate each expression if a 2 b 3 and c 4 2
- math 1310 test 3 review when uh
- c programming arithmetic and logic operations
Related searches
- common english expressions and idioms
- popular expressions and sayings
- meanings of expressions and sayings
- dictionary of expressions and idioms
- calculator for expressions and equations
- expressions and equations practice
- algebraic expressions and equations practice
- identify equations expressions and inequalities
- expressions and equations practice pdf
- expressions and equations answer key
- expressions and equations answers
- writing expressions and equations pdf