Answer to Question #244033 in C++ for ghhuh

Question #244033

Write a full program that adds three integers. Your solution should have a function named getSum that accepts three integer parameters and returns the sum of those three integers. Your main function should call the getSum function and assigns the return value to an int variable named result that is declared inside the main function. Your program should then print out the value stored in result. Submit the code and a copy of your output.


1
Expert's answer
2021-09-29T04:44:42-0400
#include <iostream>
using namespace std;
int getSum(int x,int y, int z);

int main()
{
	int num1;
	int num2;
	int num3;
	int add;


	cout<<"Enter first number: ";
	cin>>num1;
	cout<<"Enter second number: ";
	cin>>num2;
	cout<<"Enter third number: ";
	cin>>num3;


	add=getSum(num1,num2,num3);
	
	cout<<"Sum is: "<<add<<endl;
	
	return 0;
}
int getSum(int x,int y,int z)
{
	return (x+y+z);
}

Sample output:

Enter first number: 5

Enter second number: 7

Enter third number: 8

Sum is: 20


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