Pascal-arithmetic-operators
提供:Dev Guides
パスカル-算術演算子
次の表は、Pascalでサポートされているすべての算術演算子を示しています。 変数 A が10を保持し、変数 B が20を保持すると仮定します-
Operator | Description | Example |
---|---|---|
+ | Adds two operands | A + B will give 30 |
- | Subtracts second operand from the first | A - B will give -10 |
* | Multiplies both operands | A* B will give 200 |
div | Divides numerator by denominator | B div A will give 2 |
mod | Modulus Operator AND remainder of after an integer division | B mod A will give 0 |
次の例は、算術演算子を示しています-
Pascalは非常に強く型付けされたプログラミング言語であるため、整数型変数に除算の結果を保存しようとするとエラーが発生することに注意してください。 上記のコードをコンパイルして実行すると、次の結果が生成されます。