codescracker


c++

C++ Program to Add Two Numbers



« Previous Program Next Program »


Add two Numbers in C++

To add two numbers in C++ Programming, you have to ask to the user to enter the two number and place the addition of the two number in a variable of same type and print this variable on the screen which is the addition result of the two entered number as shown here in the following program.

C++ Programming Code to Add Two Numbers

Following C++ program ask to the user to enter the two number to add them and display the result on the screen:

/* C++ Program - Add Two Numbers */
		
#include<iostream.h>
#include<conio.h>
void main()
{
	clrscr();
	int a, b, sum;
	cout<<"Enter two number :";
	cin>>a>>b;
	sum=a+b;
	cout<<"Sum of the two number is "<<sum;
	getch();
}

When the above C++ program is compile and executed, it will produce the following result:

C++ program to add two numbers

Same Program in Other Language

You may like the same program in other programming languages:


« Previous Program Next Program »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test