C++ Program to Add Two Given Numbers

It is a basic C++ program that sums two given numbers. It takes two integer inputs from the user and performs arithmetic operations on them. Next, it assigns the output to a variable and then prints it on the screen.



Example C++ Program:
#include <iostream> using namespace std; int main() { /* Variable Declaration and Initialization. */ int input1, input2, output; /* Taking user input */ cout << "Please enter two integer: "; cin >> input1 >> input2; /* Adding the two numbers */ output = input1 + input2; /* Prints the output to the screen */ cout << input1 << " + " << input2 << " = " << output; return 0; }

Program Output:

Please enter two integer: 10 5 10 + 5 = 15


Found This Page Useful? Share It!
Get the Latest Tutorials and Updates
Join us on Telegram

Keep W3schools Growing with Your Support!
❤️ Support W3schools
close