Learn how to add two numbers in C++:
In this example, the user must input two numbers. Then we print the sum by calculating (adding) the two numbers:
int x, y;
int sum;
cout << "Type a number: ";
cin >> x;
cout << "Type another number: ";
cin >> y;
sum = x + y;
cout << "Sum is: " << sum;
Run example »
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!