Ads Top

PROGRAM TO FIND THE POWER OF A NUMBER

#include<conio.h>
#include<iostream.h>
void main()
{
double sum,a,i;
double power(double,double);
clrscr();
cout<<"Enter the number :";
cin>>a;
for(i=1;i<=10;i++)
{  
       sum=power(a,i);
       cout<<sum<<",";
}
cout<<"\b.";
getch();
}
double power(double x,double y)
{
double f=1,j;
for(j=0;j<y;j++)
f=f*x;
return f;

}

OUTPUT:
Enter the number:3
3,9,27,81,243,729,2187,6561,19683,59049

No comments:

Touchfeeds. Powered by Blogger.