1 //08-arithmetic operator. CPP: The entry point that defines the console application. 2 //3 4#include"stdafx.h"5#include <iostream>6#include <climits>7 using namespacestd;8 9 intMain ()Ten { One //+-*/% subtraction (die) A intA; -cout <<"Please enter the first number:"<<Endl; -Cin >> A;//cin is waiting for user input and the user does not enter the program to pause there. After the user enters, the user enters a value to a, and proceeds to the following code. the - intb; -cout <<"Please enter a second number:"<<Endl; -CIN >>b; + - intRes1 = A +b; + intRes2 = A-b; A intRes3 = A *b; at intRes4 = A/b;//The int type is divided, the result is the int type, and if it is not divisible, the part of the decimal point is omitted. - -cout << res1 <<" "<< Res2 <<" "<< Res3 <<" "<< res4 <<Endl; - //the operand of the subtraction is related to the variable type at both ends of the equals sign. - - intRES5 = -%5; incout << res5 << Endl;//both ends of the modulo operation must be integers, and C + + does not support fractional redundancy. - to //Operator Precedence: + intRES6 =3+7*3;//first multiply and then add - intRes7 =3+3;//The equals sign has the lowest priority, and the last Operation the intRes8 = (3+7) *3;//The first operation is in parentheses. * intRES9 = the/7*3;//try not to write this, it is best to use parentheses to make the need to calculate first (42/7) $cout << res6 <<" "<< res7<<" "<< Res8 <<" "<< RES9 <<Endl;Panax Notoginseng - the intT; +CIN >>T; A return 0; the}
Fundamentals of C + + programming 108-arithmetic operators