Objective-c-arithmetic-operators
提供:Dev Guides
Objective-Cの算術演算子
次の表は、Objective-C言語でサポートされているすべての算術演算子を示しています。 変数 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 |
/ | Divides numerator by denominator | B/A will give 2 |
% | Modulus Operator and remainder of after an integer division | B % A will give 0 |
++ | Increment operator increases integer value by one | A++ will give 11 |
— | Decrement operator decreases integer value by one | A-- will give 9 |
例
次の例を試して、Objective-Cプログラミング言語で使用できるすべての算術演算子を理解してください-
上記のプログラムをコンパイルして実行すると、次の結果が生成されます-