Write a C++ program to perform different arithmetic operation such as addition, subtraction, division, modulus and multiplication using inline function.

Implementation of the above problem:
#include<iostream.h>
inline int add(int a, int b)
{
return a+b;
}
inline double division(double x, double y)
{

return x/y;
}
inline float difference(float a, float b)
{
return a-b;
}
inline int modulus(int x, int y)
{
return x%y;
}
inline long int multiplication(long int a, long int b)
{
return a*b;
}
int main()
{
int a,b;
double x,y;
float i,j;
long int e,f;
cout<<"\nEnter 2 integer values for calculating there sum:\n";
cin>>a>>b;
cout<<"\nSum of "<<a<<"and "<<b<<" = "<<add(a,b)<<"\n";
cout<<"\nEnter 2 double values for performing division:\n";
cin>>x>>y;
cout<<"\nValue of "<<x<<" divided by "<<y<<" = "<<division(x,y)<<"\n";
cout<<"\nEnter 2 float values for calculating there difference :\n";
cin>>i>>j;
cout<<"\nDifference between "<<i<<" and "<<j<<" = "<<difference(i,j)<<"\n";
cout<<"Enter 2 integer values for calculating there modulus:\n";
cin>>a>>b;
cout<<"\n"<<a<<" modulus "<<b<<" = "<<modulus(a,b)<<"\n";
cout<<"\nEnter 2 long integer values for calculating there product:\n";
cin>>e>>f;
cout<<"\nProduct of "<<e<<" and "<<f<<" = "<<multiplication(e,f)<<"\n";
return 0;
}


Thanks
Mukesh Rajput
Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

4 comments:

  1. factorial hundred In the last few days, the “factorial of 100” is one of the top subjects and a lot of maths geeks compute it using voice assistants such as Alexa, Shiri, etc.

    ReplyDelete