C++ Program to add two integers

Simple C++ program to add two integers:
#include<iostream>
using namespace std;
int main(){
 int n,m,sum;
 cout<<"Enter two integer \n";
 cout<<"Enter first integer: ";
 cin>>m;
 cout<<"Enter second integer: ";
 cin>>n;
 sum=m+n;
 cout<<"Sum of "<<m<<" and "<<n<<" = "<<sum;
 return 0;
}
Another C++ program to add two integers using function
#include<iostream>
int SumOfInteger(int m,int n)
{
 int sum=m+n;
 return sum;
}
using namespace std;
int main(){
 int n,m,sum;
 cout<<"Enter two integer \n";
 cout<<"Enter first integer: ";
 cin>>m;
 cout<<"Enter second integer: ";
 cin>>n;
 sum=SumOfInteger(m,n);
 cout<<"Sum of "<<m<<" and "<<n<<" = "<<sum;
 return 0;
}



Popular posts from this blog