0
I can't understand this part
#include <iostream> using namespace std; int main() { int a, b; int sum; cout << "Enter a number \n"; cin >> a; cout << "Enter another number \n"; cin >> b; sum = a + b; cout << "Sum is: " << sum << endl; return 0; } Someone explain what is sum is and why it was used ?
1 Answer
+ 8
Sum is an additional variable that is used for adding other two input variables a&b.
You can do this if you don't want to use Sum variable.
cout<< "Sum is:" << a + b << endl;