解释C语言中算术运算符的概念
它用于执行算术运算,例如加法,减法等。
算法
遵循以下提到的算法-
START Step 1: Declare integer variables. Step 2: Read all variables at runtime. Step 3: Perform arithmetic operations. i. a+b ii. a-b iii. a*b iv. b/a v. a%b Step 4: Print all computed values.
示例
以下是用于计算算术运算符的C程序-
#include输出结果main (){ int a,b; printf("enter a,b:\n"); scanf("%d%d",&a,&b); printf("a+b=%d\n",a+b); printf("a-b=%d\n",a-b); printf("a*b=%d\n",a*b); printf("b/a=%d\n",b/a); printf("a%b=%d\n",a%b); }
您将看到以下输出-
enter a,b: 40 60 a+b=100 a-b=-20 a*b=2400 b/a=1 ab=40