View the step-by-step solution to:

Generate a program using a function that accepts two integers as input arguments and return their sum.

Generate a program using a function that accepts two integers as input arguments and return their sum. Call this function from main( ) and call another function from main( ) that prints the result (sum). Thus, you need two separate functions besides main( ).


#include<iostream>

using namespace std;

int getSum(int, int);

int main()
{
	int number1, number2, sum;
	
	
	cout<<"Enter two integers to add"<<endl;
	
	
	
??????


	sum = getSum(number1, number2);
	
	
	cout<<number1<<" + "<<number2<<" = "<<sum;
}


HOW TO CREATE FUNCTION FOR USER INPUT?

int getSum(int x, int y)
{
	return x + y;
}


so I am getting up to this point that I have trouble creating a separate function to take user input and link it back to the main function. Any help is appreciate.

Top Answer

You need to add a function that accepts value as... View the full answer

Capture.PNG

1 comment
  • Thanks for the explanation!
    • michael0719
    • Apr 04, 2018 at 11:27pm

Sign up to view the full answer

Other Answers

int main () { int number1, number2, sum; cout &lt;&lt; "Enter two integers to... View the full answer

1 comment
  • Thank you!
    • michael0719
    • Apr 04, 2018 at 11:28pm

Following is the corrected code for your problem: include the header files #include&lt;iostream&gt; using namespace std ;... View the full answer

121.png

1 comment
  • Thank you so much!
    • michael0719
    • Apr 05, 2018 at 4:39pm

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.

-

Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask a homework question - tutors are online