gfgdf

#include <iostream>

int main() {
    int num1, num2, sum;

    // Input
    std::cout << "Enter two numbers: ";
    std::cin >> num1 >> num2;

    // Addition
    sum = num1 + num2;

    // Output
    std::cout << "Sum: " << sum;

    return 0;
}

Explanation:

  1. #include <iostream>: This line includes the input/output stream library in the program.

  2. int main() {: This line declares the main function, the starting point of execution for C++ programs.

  3. int num1, num2, sum;: Declares three integer variables num1, num2, and sum to store input numbers and their sum.

  4. std::cout << "Enter two numbers: ";: Displays the prompt to enter two numbers on the console.

  5. std::cin >> num1 >> num2;: Takes input from the user for num1 and num2.

  6. sum = num1 + num2;: Calculates the sum of num1 and num2 and assigns it to the variable sum.

  7. std::cout << "Sum: " << sum;: Displays the result (sum) on the console.

  8. return 0;: Indicates successful program execution and returns 0 to the operating system.

  9. }: Marks the end of the main function and the end of the program.