This preview shows pages 1–2. Sign up to view the full content.
9/12/2011
1
CMSC 106
Lecture Set #3
Set Started:
Monday, September 12, 2010
Common Operators
s
Arithmetic operators
:
s
Unary negation:
x
s
Addition/subtraction:
x+y
xy
s
Multiplication/division:
x*y
x/y
s
Division between integer types
truncates
to integer:
23/4
→
5
s
x%y
returns the
remainder
of
x
divided by
y
:
23%4
→
3
s
Division with real types yields a real result:
23.0/4.0
→
5.75
s
Same rules as algebra for precedence and associatively
s
Comparison operators
:
s
Equality/inequality:
x == y
x != y
s
Less than/greater than:
x < y
x > y
s
Less than or equal/greater than or equal:
x <= y
x >= y
(ex: operators.c, truncation.c and rounding.c)
The Assignment Operator
s
variable = value
s
LHS must indicate space in memory
s
RHS must have value
s
should be of the same type
s
calculated before assignment
s
Both: A Statement and An Arithmetic Operator
s
changes the value of the space indicated by the LHS
s
returns the value that is assigned
s
right to left associative
(ex: assignments.c)
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview. Sign up
to
access the rest of the document.
This note was uploaded on 01/12/2012 for the course CMSC 106 taught by Professor Staff during the Fall '07 term at Maryland.
 Fall '07
 staff

Click to edit the document details