Monday, January 31, 2011

Functions in C++

#include<iostream>
#include<conio.h>
using namespace std;
double raisetopower(double k,int j)
{
       int i;
       double result=1;
       for(i=1;i<=j;i++)
       result=result*k;
       return(result);
       }
main()
{
int power;
double number,x;
cout<<"enter the number whose power you want to find:";
cin>>number;
cout<<"enter the power you want to find of a number:";
cin>>power;
x=raisetopower(number,power);
cout<<x;
getch();
}

No comments:

Post a Comment