C++ Program to Add Two Numbers

C++ Program to add two numbers. This program will add two numbers in result with the third variable in c++ to print the addition of two numbers in the c++ 

#include <iostream>
using namespace std;
int main()
{
int a, b, c;
cout << "Enter two integers: ";
cin >> a >> b;
c = a + b;
cout << a << " + " << b << " = " << c; 
return 0;
}

 

Output:

Enter two integers:

45

45

45 + 45 = 90

Operator in C++

Operators are a subset of functions that take one or more arguments and return a new value. 

Operators include things like addition (+), subtraction (-), multiplication (*), and so on. 

Variables and constants are operated on with the use of operators.

Namespace in C++

You may specify the context in which names are defined by using namespace. 

A namespace, in essence, establishes a scope. C++ includes a standard library that contains common features like containers and algorithms that you’ll utilize in your programs.

Return Statement in C++

A return statement terminates a function’s execution and returns control to the calling function. 

At the point immediately following the call, execution resumes in the calling function. 

A return statement can return a value to the function that called it. The execution of a function is terminated, and control is returned to the calling function. 

At the point immediately following the call, execution resumes in the calling function.