Social Icons

Saturday, 15 February 2014

Program to raise any number x to a positive power n

#include<iostream.h>
#include<conio.h>
#include<math.h>              //for pow() function

void main()
{
clrscr();
int x,n,res;
cout<<"\n Enter value of x : ";
cin>>x;
cout<<"\n Enter value of n : ";
cin>>n;

res=pow(x,n);            //to calculate power
cout<<"\n\t Result = "<<res;
getch();
}


                                                               Output

No comments:

Post a Comment