# C語言算術運算範例程式

### 加法操作

``````#include <stdio.h>

int main() {
int op1, op2, sum;      // variable declaration

op1 = 5;                // variable definition
op2 = 3;
sum = op1 + op2;        // addition operation
printf("sum of %d and %d is %d", op1, op2, sum);
}
``````

``````sum of 5 and 3 is 8
``````

### 減法運算

C語言中的減法運算，如下面給出的範例程式碼 -

``````#include <stdio.h>

int main() {
int op1, op2, sub;      // variable declaration
op1 = 5;                // variable definition
op2 = 3;
sub = op1 - op2;        // subtraction operation
printf("Output of %d ? %d is %d", op1, op2, sub);
}
``````

``````Output of 5 ? 3 is 2
``````

### 乘法運算

``````#include <stdio.h>

int main() {
int op1, op2, mul;      // variable declaration

op1 = 5;                // variable definition
op2 = 3;

mul = op1 * op2;        // multiplication operation

printf("Output of %d multiplied by %d is %d", op1, op2, mul);
}
``````

``````Output of 5 multiplied by 3 is 15
``````

### 除法運算

``````#include <stdio.h>

int main() {
int op1, op2, div;      // variable declaration
op1 = 6;                // variable definition
op2 = 3;

div = 6 / 3;            // division operation

printf("Output of %d divide by %d is %d", op1, op2, div);
}
``````

``````Output of 6 divide by 3 is 2
``````