算术运算符:
下表是显示了C语言支持的所有算术运算符 。假设变量A的值是10,变量B的值是20 。

文章插图
创建源代码文件:marithmetic_operators.c,代码如下:
#include <stdio.h>
void main() {
int a = 21;
int b = 10;
int c ;
c = a + b;
printf("Line 1 - Value of c is %dn", c );
c = a - b;
printf("Line 2 - Value of c is %dn", c );
c = a * b;
printf("Line 3 - Value of c is %dn", c );
c = a / b;
printf("Line 4 - Value of c is %dn", c );
c = a % b;
printf("Line 5 - Value of c is %dn", c );
c = a++;
printf("Line 6 - Value of c is %dn", c );
c = a--;
printf("Line 7 - Value of c is %dn", c );
}
执行上面的代码,得到如下结果:
Line 1 - Value of c is 31
Line 2 - Value of c is 11
Line 3 - Value of c is 210
【C语言运算符之算术运算符】Line 4 - Value of c is 2
Line 5 - Value of c is 1
Line 6 - Value of c is 21
Line 7 - Value of c is 22
推荐阅读
- 打造绿茶之都 走优质茶叶发展之路
- 中国黄茶之乡花落湖南岳阳
- 皮囊之下李黛萱为什么 皮囊之下女主是姐姐还是妹妹
- 做过爱的人见面会尴尬吗 男女一旦有了肌肤之亲一辈子都不会忘记吗
- 从西双版纳到大吉岭的寻茶之路
- 荈赋,咏茶品茗的精美之作
- 茶叶加工之蒸青绿茶历史名优茶叶绍介
- 兼具铁观音和红茶特性之清源红泉州问世
- 茶思茶韵 虚静之美
- 棉花被可以暴晒吗 棉花被收起来之前要晒吗
