Operator Overloading

link 0

/* C++ program to find the power of a given number using operator overloading concept*/

#include<iostream.h>
#include<conio.h>
#include<math.h>
int power(int,int);
float power(float,float);
void main()
{
int b,p,r;

float br,pr,rr;
clrscr();
cout<<“enter the integer base and integer power”;
cin>>b>>p;
cout<<“enter the real base and real power”;
cin>>br>>pr;
r=power(b,p); /* first function will be called*/
rr=power(br,pr); /* second function will be called*/
cout<<“the power of”<<b<<“and”<<p<<“is”<<r;
cout<<“\n”<<“the power of”<<br<<“and”<<pr<<“is”<<rr;
}
int power(int a,int b)
{
return pow(a,b);
}
float power(float c,float d)
{
return pow(c,d);
}

Output:
enter the integer base and integer power
2
2
enter the real base and real power
1.2
3.2
the power of 2 and 2 is 4
the power of 1.2 and 3.2 is 1.792

We have built the accelerating growth-oriented website for budding engineers and aspiring job holders of technology companies such as Google, Facebook, and Amazon
If you would like to study our free courses you can join us at

http://www.techcodebit.com. #techcodebit #google #microsoft #facebook #interview portal #jobplacements
#technicalguide

rakesh

Leave a Reply

Your email address will not be published. Required fields are marked *

Skip to toolbar