Saturday, March 5, 2011

Operator Aritmetika dan Logika Pada Pascal

OPERATOR ARITMETIKA
Uses crt;
Var
X, y: integer;
Begin
Clrscr;
Write (‘Masukan nilai x : ‘); readln (x);
Write (‘Masukan nilai y : ‘); readln (y);
Writeln;

Writeln (‘x +y = ‘ , x + y);
Writeln (‘x – y = ‘ , x – y);
Writeln (‘x * y = ‘ , x * y);
Writeln (‘x / y = ‘ , x / y);
Writeln (‘x div y = ‘ , x div y);
Writeln (‘x mod y = ‘ , x mod y);
Readln;
End.

OPERATOR LOGIKA
Program OperatorAnd;
Uses crt;
Begin
Clrscr;
Writeln (‘TRUE and TRUE = ‘ , true and true);
Writeln (‘TRUE and FALSE = ‘ , true and false);
Writeln (‘FALSE and TRUE = ‘ , false and true);
Writeln (‘FALSE and FALSE = ‘ , false and false);
Readln;
End.

Program OperatorOr;
Uses crt;
Begin
Clrscr;
Writeln (‘TRUE or TRUE = ‘ , true or true);
Writeln (‘TRUE or FALSE = ‘ , true or false);
Writeln (‘FALSE or TRUE = ‘ , false or true);
Writeln (‘FALSE or FALSE = ‘ , false or false);
Readln;
End.

Program OperatorXor;
Uses crt;
Begin
Clrscr;
Writeln (‘TRUE xor TRUE = ‘ , true and true);
Writeln (‘TRUE xor FALSE = ‘ , true and false);
Writeln (‘FALSE xor TRUE = ‘ , false and true);
Writeln (‘FALSE xor FALSE = ‘ , false and false);
Readln;
End.

No comments: