📅  最后修改于: 2020-09-25 05:57:33             🧑  作者: Mango
#include
using namespace std;
int main()
{
int firstNumber, secondNumber, sumOfTwoNumbers;
cout << "Enter two integers: ";
cin >> firstNumber >> secondNumber;
// sum of two numbers in stored in variable sumOfTwoNumbers
sumOfTwoNumbers = firstNumber + secondNumber;
// Prints sum
cout << firstNumber << " + " << secondNumber << " = " << sumOfTwoNumbers;
return 0;
}
输出
Enter two integers: 4
5
4 + 5 = 9
在此程序中,要求用户输入两个整数。这两个整数分别存储在变量firstNumber
和secondNumber
。
然后,使用+ 运算符将变量firstNumber
和secondNumber
相加并存储在sumOfTwoNumbers
变量中。
最后,在屏幕上显示sumOfTwoNumbers
。