Answer to Question #324589 in C++ for Secret Agent

Question #324589

Pairing Up


by CodeChum Admin



You’re tasked with pairing up people with each other but you need to figure out how well both of them work together. In order to find out how effective each pair is, you need to create a program that adds both of their values and returns their sum.





Instructions:



In the code editor, you are provided with a main() function that asks the user for two integer inputs, passes these to a function called, getSum(), and then prints the returned value.


Your task is to declare and define the getSum() function which has the following details:


Return type - int


Name - getSum


Parameters - 2 integers


Description - adds the passed integers and returns their sum


DO NOT EDIT ANYTHING IN THE MAIN


Input



1. First integer



2. Second integer



Output



Enter·first·number:·24


Enter·second·number:·21


Sum·=·45

1
Expert's answer
2022-04-06T02:27:47-0400




#include<iostream>


using namespace std;


int getSum(int a,int b){
	return a+b; 
}


int main()
{
	int a,b;
	
	cout<<"Enter first number: ";
	cin>>a;
	cout<<"Enter second number: ";
	cin>>b;
	cout<<"Sum = "<<getSum(a,b)<<"\n\n";
	
	
	system("pause");
	return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS