Program to print addition of two number using C++

 Here is a simple C++ program to print the addition of two numbers:

Program: Addition of Two Numbers in C++

#include <iostream>
using namespace std; int main()
{
int a, b, sum;
// Input two numbers
cout << "Enter first number: ";
cin >> a; cout <<
cout << "Enter second number: ";
cin >> b;
// Calculate sum
sum = a + b;
// Display result
cout << "The sum is: " << sum << endl;
return 0;
}



second step

#include<iostream>
using namespace std;
int main()
{
int a,b,sum;
cout<<"enter the value of a and b"<<endl;
cin>>a>>b;
sum=a+b;
cout<<"the sum is"<<sum;
return 0;
}

Previous Post Next Post

Contact Form