#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;
}
Comments
Leave a comment