C++ Program to add two numbers


In this Example, You will learn how to Add Two numbers in C++.


20 = 10 + 10

40 = 20 + 20

Example: How to Add Two numbers in C++.

#include<iostream>
using namespace std;

int main() {

    int x, y, s;

    cout << "Enter two numbers:";
    cin >> x >> y;

    s = x + y;

    cout << "Sum of two numbers is:" << s;

    return 0;
}

Output:

Enter two numbers:10 20
Sum of two numbers is:30