# Math Help - C++ programming. i urgently need help in this.plz help me!

1. ## C++ programming. i urgently need help in this.plz help me!

Write a C++ program that uses the following function that computes xn.

2. ## Re: C++ programming. i urgently need help in this.plz help me!

That's very peculiar. Any caculator will do that easily and Windows includes a "virtual" calculator that will. So why do you need such a program?

If this is for a class in C++ programming, I would think the point would be for you to write the program!

I will tell you this much- for the actual calculation, and assuming that n is an integer, use a loop:
\*************\
func nthPower(real x; int n)
int p= 1; \* initialize p*\
for (int i= 0;i++;i< n) \* go through the loop n times*\
\** what do you think goes here? **\
return p;
\*************\

The fornat may not be exactly right. It has been a long time since I programmed in C++!

(if n is not an integer you may want to use $x^n= e^{nln(x)}$)

3. ## Re: C++ programming. i urgently need help in this.plz help me!

Hi Riana!

Something like this?

Code:
#include <cmath>
#include <iostream>

using namespace std;

int main(void)
{
double x = 2.72;
double n = 6;
cout << pow(x, n) << endl;
return 0;
}

4. ## Re: C++ programming. i urgently need help in this.plz help me!

thankx everyone but later on i figured out