C++20 sections · 1024 units
Open in Course

Sum of Two - Implementation

Working solution

Here's the complete solution. I declare two variables a and b to store the input numbers. Then I read them using cin, compute their sum, and output it. Notice how each line corresponds to one step in your mental model.

#include <iostream>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    cout << a + b << endl;
    return 0;
}
``` You could also store the sum in a separate variable before printing. Both approaches work, but direct output is shorter. The important part is understanding why each line is necessary and what data flows through your program.