C ++中的简单算术运算符示例程序

C ++具有5个基本的算术运算符。他们是-

  • 加法(+)

  • 减法(-)

  • 师(/)

  • 乘法(*)

  • 模数(%)

这些运算符可以对C ++中的任何算术运算进行运算。让我们看一个例子-

#include <iostream>
using namespace std;
main() {
   int a = 21;
   int b = 10;
   int c ;
   c = a + b;
   cout << "Line 1 - Value of c is :" << c << endl ;
   
   c = a - b;
   cout << "Line 2 - Value of c is  :" << c << endl ;
   
   c = a * b;
   cout << "Line 3 - Value of c is :" << c << endl ;
   
   c = a / b;
   cout << "Line 4 - Value of c is  :" << c << endl ;
   
   c = a % b;
   cout << "Line 5 - Value of c is  :" << c << endl ;
   return 0;
}

输出结果

这将给出输出-

Line 1 - Value of c is :31
Line 2 - Value of c is  :11
Line 3 - Value of c is :210
Line 4 - Value of c is  :2
Line 5 - Value of c is  :1