什么是C#中的算术运算符?
运算符是一个符号,告诉编译器执行特定的数学或逻辑操作。
让我们看一个在C#中使用算术运算符的示例。
示例
using System;
namespace Demo {
class Program {
static void Main(string[] args) {
int a = 99;
int b = 33;
int c;
c = a + b;
Console.WriteLine("Value of c is {0}", c);
c = a - b;
Console.WriteLine("Value of c is {0}", c);
c = a * b;
Console.WriteLine("Value of c is {0}", c);
c = a / b;
Console.WriteLine("Value of c is {0}", c);
c = a % b;
Console.WriteLine("Value of c is {0}", c);
c = a++;
Console.WriteLine("Value of c is {0}", c);
c = a--;
Console.WriteLine("Value of c is {0}", c);
Console.ReadLine();
}
}
}输出结果
Value of c is 132 Value of c is 66 Value of c is 3267 Value of c is 3 Value of c is 0 Value of c is 99 Value of c is 100
热门推荐
10 姨父生日祝福语简短精辟
11 幼儿老师过年简短祝福语
12 保持快乐祝福语大全简短
13 朋友明天手术祝福语简短
14 祝愿女孩成长祝福语简短
15 送给客户的祝福语 简短
16 新人结婚简短祝福语大全
17 中式婚礼贺词祝福语简短
18 对美好前程祝福语简短