Articles

C++ program to perform arithmetic sum

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:

 


CPP Programs

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  
Please Share this page

Related Articles

Like every other website we use cookies. By using our site you acknowledge that you have read and understand our Cookie Policy, Privacy Policy, and our Terms of Service. Learn more Got it!