26.8.15

Implement function overloading

Write a C++ program to implement function overloading in order to compute power(m,n) where i) m is double and n is int ii) m and n are int.

#include<iostream.h>

#include<conio.h>
#include<math.h>

int power(int a,int b);

double power(int i, double d);

int main()

{

int i1,i2,i3; double d1; clrscr();
cout<<"\nEnter Two Integer Numbers To Calculate Power : "; cin >>i1>>i2;
int p1=power(i1,i2);

cout<<"\nThe Power of "<<i1<<" and "<<i2<<" is : "<<p1; cout<<"\n\nEnter One Integer And One Double To calculate power :"; cin>>i3>>d1;

double p2=power(i3,d1);

cout<<"\nThe Power of "<<i3<<" and "<<d1<<" is : "<<p2; getch();
return(0);

}

int power(int a,int b)

{
return(pow(a,b));
}
double power(int i, double d)
{
return(pow(i,d));
}


********************************OUTPUT**********************************

Enter Two Integer Numbers To Calculate Power : 2  4

The Power of 2 and 4 is : 16

Enter One Integer And One Double To calculate power :2 2.5


The Power of 2 and 2.5 is : 5.656854

17 comments:

  1. You are doing a great job. You inspire me to write for other. Thank you very much. I would like to appreciate your work for good accuracy and got informative knowledge from here. Python Training in Chennai

    ReplyDelete
  2. Excellent information...It was getting more information about your blog. Thanks for sharing, keep updating.
    Best cloud Computing Training Institute in Chennai | Best cloud Computing Training Institute in Velachery

    ReplyDelete
  3. Play online casinos with fun and money fun slots Fun money, take while there.

    ReplyDelete
  4. Yesterday I came to visit my sister and we decided to have fun and play online casinos, polazili on a bunch of sites and this one caught my eyeunforgettable gambling statistics Here we quickly figured out what was happening and began to think quickly about the strategy. and we found her now we take money out of here every day

    ReplyDelete
  5. Great post!
    Thanks for sharing this list!
    It helps me a lot finding a relevant blog in my niche!
    Java Training in Chennai
    Java Training in Coimbatore
    Java Training in Bangalore

    ReplyDelete

Comment Here