Answer to Question #238450 in C++ for ali

Question #238450
Write following functions and demonstrate their working using a program.
1- Sum Function (takes two integer parameters and returns their sum)
2- Difference Function (takes two integer parameters and returns their difference)
3- Product Function (takes two integer parameters, performs division, returns product)
4- Quotient Function (takes two integer parameters, performs division, returns quotient)
5- Remainder Function (takes two integer parameters, performs division and returns remainder)
1
Expert's answer
2021-09-17T08:30:22-0400
#include <iostream>
#include <string>
#include <iomanip>


using namespace std;




//Write following functions and demonstrate their working using a program.


//1- Sum Function (takes two integer parameters and returns their sum)
int Sum(int number1,int number2){
	return number1+number2;
}
//2- Difference Function (takes two integer parameters and returns their difference)
int Difference(int number1,int number2){
	return number1-number2;
}
//3- Product Function (takes two integer parameters, performs division, returns product)
int Product(int number1,int number2){
	return number1*number2;
}
//4- Quotient Function (takes two integer parameters, performs division, returns quotient)
float Quotient(int number1,int number2){
	return float(number1)/(float)number2;
}
//5- Remainder Function (takes two integer parameters, performs division and returns remainder)
int Remainder(int number1,int number2){
	return number1%number2;
}


int main(){
	int number1;
	int number2;
	cout << "Ente the number 1: ";
	cin>>number1;
	cout << "Ente the number 2: ";
	cin>>number2;


	cout<<"Sum: "<<Sum(number1,number2)<<"\n";
	cout<<"Difference: "<<Difference(number1,number2)<<"\n";
	cout<<"Product: "<<Product(number1,number2)<<"\n";
	cout<<"Quotient: "<<Quotient(number1,number2)<<"\n";
	cout<<"Remainder: "<<Remainder(number1,number2)<<"\n";




	cin>>number2;
	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