简单算术程序代码是什么

时间:2025-01-30 07:17:44 手机游戏

加法:

```c

include

int main() {

int a = 5, b = 3;

int sum = a + b;

printf("Sum: %d

", sum);

return 0;

}

```

减法:

```c

include

int main() {

int a = 5, b = 3;

int difference = a - b;

printf("Difference: %d

", difference);

return 0;

}

```

乘法:

```c

include

int main() {

int a = 5, b = 3;

int product = a * b;

printf("Product: %d

", product);

return 0;

}

```

除法:

```c

include

int main() {

int a = 10, b = 2;

int quotient = a / b;

printf("Quotient: %d

", quotient);

return 0;

}

```

取余数:

```c

include

int main() {

int a = 10, b = 3;

int remainder = a % b;

printf("Remainder: %d

", remainder);

return 0;

}

```

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