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 variablesnum1
,num2
, andsum
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 variablenum1
.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 variablenum2
.sum = num1 + num2;
: Calculates the sum ofnum1
andnum2
and stores the result in the variablesum
.cout << "The sum is: " << sum << endl;
: Displays the sum ofnum1
andnum2
.return 0;
: Indicates successful completion of themain()
function and the program terminates.