download pascal tutorial (pdf - Tutorials Point
download pascal tutorial (pdf - Tutorials Point
download pascal tutorial (pdf - Tutorials Point
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
program beBitwise;<br />
var<br />
a, b, c: integer;<br />
begin<br />
a := 60; (* 60 = 0011 1100 *)<br />
b := 13; (* 13 = 0000 1101 *)<br />
c := 0;<br />
c := a and b; (* 12 = 0000 1100 *)<br />
writeln('Line 1 - Value of c is ', c );<br />
c := a or b; (* 61 = 0011 1101 *)<br />
writeln('Line 2 - Value of c is ', c );<br />
c := not a; (* -61 = 1100 0011 *)<br />
writeln('Line 3 - Value of c is ', c );<br />
c := a > 2; (* 15 = 0000 1111 *)<br />
writeln('Line 5 - Value of c is ', c );<br />
end.<br />
When the above code is compiled and executed, it produces the following result:<br />
Line 1 - Value of c is 12<br />
Line 2 - Value of c is 61<br />
Line 3 - Value of c is -61<br />
Line 4 - Value of c is 240<br />
Line 5 - Value of c is 15<br />
Operators Precedence in Pascal<br />
Operator precedence determines the grouping of terms in an expression. This affects how an<br />
expression is evaluated. Certain operators have higher precedence than others; for example,<br />
the multiplication operator has higher precedence than the addition operator.<br />
For example x = 7 + 3 * 2; here, x is assigned 13, not 20 because operator * has higher<br />
precedence than +, so it first gets multiplied with 3*2 and then adds into 7.<br />
Here, operators with the highest precedence appear at the top of the table, those with the<br />
lowest appear at the bottom. Within an expression, higher precedence operators will be<br />
evaluated first.<br />
Operators<br />
Precedence<br />
~, not, Highest<br />
*, /, div, mod, and, &<br />
|, !, +, -, or,<br />
TUTORIALS POINT<br />
Simply Easy Learning Page 29