shout sharkest

#include <iostream>
using namespace std;

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

    cout << "Enter first number: ";
    cin >> num1;

    cout << "Enter second number: ";
    cin >> num2;

    sum = num1 + num2;

    cout << "The sum is: " << sum << endl;

    return 0;
}

Explanation:

  • #include <iostream>: Includes the input-output stream header file for handling input and output operations.
  • using namespace std;: Allows the usage of functions and objects in the standard C++ library.
  • int main() { ... }: Entry point of the program; execution starts from here.
  • int num1, num2, sum;: Declares three integer variables num1, num2, and sum to store input and the sum.
  • cout << "Enter first number: ";: Displays a message asking the user to enter the first number.
  • cin >> num1;: Reads the input from the user and stores it in the variable num1.
  • cout << "Enter second number: ";: Displays a message asking the user to enter the second number.
  • cin >> num2;: Reads the input from the user and stores it in the variable num2.
  • sum = num1 + num2;: Calculates the sum of num1 and num2 and stores the result in the variable sum.
  • cout << "The sum is: " << sum << endl;: Displays the sum of num1 and num2.
  • return 0;: Indicates successful completion of the main() function and the program terminates.