365读书网-读万卷书行万里路

365读书网-读万卷书行万里路

c语言简单的算术运算代码?

59

加法

```c

include

int main() {

int a = 5;

int b = 3;

int sum = a + b;

printf("The sum is %d

", sum);

return 0;

}

```

减法

```c

include

int main() {

int a = 5;

int b = 3;

int diff = a - b;

printf("The difference is %d

", diff);

return 0;

}

```

乘法

```c

include

int main() {

int a = 5;

int b = 3;

int product = a * b;

printf("The product is %d

", product);

return 0;

}

```

除法

```c

include

int main() {

int a = 5;

int b = 3;

int quotient = a / b;

printf("The quotient is %d

", quotient);

return 0;

}

```

取余数

```c

include

int main() {

int a = 5;

int b = 3;

int remainder = a % b;

printf("The remainder is %d

", remainder);

return 0;

}

```

这些示例展示了如何在 C 语言中执行基本的算术运算,并将结果打印到控制台。每个示例都包含了一个简单的 `main` 函数,用于执行运算并输出结果。