This preview shows page 1. Sign up to view the full content.
Unformatted text preview: a very small number, say 0.0 followed by 5000 0's followed
by a 1, not even a l n d u l can store that value. Overflow and underflow should be rare for
og obe
the programs we are interested in, however. Variable naming
Here are the rules for naming variables:
1 to 255 characters
must begin with a letter or _
after the first letter or _ can contain numbers
,
uppercase and lowercase letters are considered different (e.g. x zis not the same variable as
y
Xz
y)
"reserved" words cannot be used (e.g. "using" "namespace" "if" "else" etc.)
do not use all uppercase letters unless the variable is a "constant" ("constant" means its value
never changes; e.g. c n t d u l P = 3 1 1 9is a proper use of all uppercase letters)
os obe I
.45 Declaring variables
You can declare multiple variables in one line (separated by commas), if they are all of the same
type:
dul a b c d e f g
obe , , , , , , ;
itx y z
n ,,; You can also give them values: dul a=11 b=22 c=33
obe
.,
.,
.;
itx=1 y=2 z=3
n
,
,
; Declare and define constant values like this (using all caps for the variable names):
cntdul P =3119
os obe I
.45;
cntitMLILE =5
os n UTPIR
; Because these variables have the modifier c n t you are not allowed to change their values (the
os,
compiler will display an error if you try). Arithmetic
Here are the normal math operators that work on integers and floating point numbers:
+(add)
(subtract; or a negative number, e.g. i t x =  )
n
5 *(multiply) Here are somewhatunique math operators that work with integers:
/(quotient: 1 / 5is 2
3 because 5 goes into 13 two times) %(remainder: 1 % 5is 3
3 because the remainder of 5/13 is 2) Note that /works as you would expect with floating point numbers (e.g. 1 2 / 5 6is about
.
.
0.214).
Precedence works the same as you would expect: * / %happen before + so ( + 6 % 4  (
5
3
+ 4 / 2 equals 4
)
) as you would expect. You can use parentheses to clarify the math. Arithmetic shorthand
You...
View
Full
Document
This note was uploaded on 05/23/2013 for the course CSE 202 taught by Professor Staff during the Winter '12 term at Ohio State.
 Winter '12
 Staff

Click to edit the document details