C++ program to perform arithmetic sum
In this chapter of C++ program tutorial our task is to :
-
Write a C++ program to accept user inputs
-
Perform arithmetic sum operation on the given inputs
-
Output the required solution on console
Given below is a C++ program to accept user input and perform arithmetic sum operation on it.
#include<iostream>
using namespace std;
int main()
{
int a,b,c;
cout<<"Enter the two numbers giving a space"<<endl;
cin>>a>>b;
c = a + b;
cout<<c<<endl;
return 0;
}
OUTPUT :
Enter the two numbers giving a space.
3 7
10
Explanation:
In the above code:
-
the compiler enters the main function (here int main()), and then creates each of 4 bits of memory space for variables a,b and c.
-
Then it takes the two integer as input and then store the value of a+b in a new variable c.
-
The c variable is then displayed in the output screen.
You can see the above code execution and output in codeblocks IDE:
Would you like to see your article here on tutorialsinhand.
Join
Write4Us program by tutorialsinhand.com
About the Author
Sayantan Bose
- š Iām currently working on DS Algo skills
- š± Iām currently learning web develeopement
- šÆ Iām looking to collaborate with Oppia
- š« Reach me at https://www.linkedin.com/in/sayantan-bose-14134a1a6/
- š Pronouns: his/him
Page Views :
Published Date :
Jul 24,2020