In this tutorial, you will learn how to write a C++ Program to find the sum of two numbers.
C++ Sum of Two Numbers
To find sum of two numbers in C++, use Arithmetic Addition Operator (+). Pass the two numbers as operands to the Addition Operator, and it returns the sum of two numbers.
Program
In the following C++ Program, we read two numbers from user, and find their sum.
main.cpp
</>
Copy
#include <iostream>
using namespace std;
int main() {
int a, b;
cout << "Enter first number : ";
cin >> a;
cout << "Enter second number : ";
cin >> b;
int sum = a + b;
cout << "Sum : " << sum << endl;
}
Output
Enter first number : 4
Enter second number : 5
Sum : 9
Program ended with exit code: 0
Enter first number : 4
Enter second number : 1
Sum : 5
Program ended with exit code: 0
Conclusion
In this C++ Tutorial, we learned how to add two numbers using Arithmetic Addition Operator.