Professional Documents
Culture Documents
&
Variables
Data Types
Keywords
To declare
variable of type
Integer
int
Integers, eg:
33000,45,2,-9,98765
Character
char
A single
character,, eg:
A,*,+,m,\
Single precision
floating point
float
A floating point
number, eg: 1.23,0.09,45.0
Double precision
floating point
double
A floating point
with double
precision.
Eg: 1.7976973 X
(10^308)
Variables
Sumexamples
Total of variable
Average
Area_circle
Some
names
are:
Declaration of Variables
Initialization
Examples:
x=y=z=0;
m=n=20;
Global Variables
Statements
Examples:
X=4+j;
Y=10-m;
Z= x+y;
1.
3.
4.
Output Statement
\r = Carriage
return
\ = Double
quote
\t = Tab
\f = Form feed
\\ = Backslash
\b = Backspace
\ = Single
quote
Input Statement
Assignment Statement
Operators
Operator
Example
Multiplication
x*y
Division
x/y
Addition
x+y
Substraction
x-y
Modulus
x%y
Order of Evaluation
Arithmatic Operators
Operation
Operator
Order of Evaluation
Parentheses
()
Multiplication
, division and
modulus
*,/ or %
Addition and
subtraction
+ and -
Operator
Example
Equal
==
x==y
Not equal
!=
x!=y
Less than
<
x<y
<=
x<=y
Greater than
>
x>y
>=
x>=y
Examples
Expressions
Evaluate as
Interpretation
4==2
False
3>2
True
4!=7
True
(5+5) == (2*5)
True
Logical/Boolean
Operators
Operator
And
&&
Or
||
Not
Continue..
P && Q
Continue..
P||Q
Continue..
!P
Example
Expressions
Evaluate as
interpretation
true
(4>1) || (5<2)
true
false
!(5==3)
true
Exercise
Output
Exercise
Evaluate as
interpretation