Write a program that computes XN where X is a floating point number and N is a positive integer. The program informs the user that N must be positive if the user enters a negative value. Of course,
XN = X * X * X * ... * X
--------------------
N times
The user dialog will look something like this:
Enter X
1.3
Enter N
5

1.3 raised to the power 5 is: 3.71293

-------

Enter X
5.6
Enter N
-3

N must be a positive integer.

can u help me 2 solve this problem,i need this for my project.

Recommended Answers

Sure, what do you have so far? In general, you won't get much help without showing that you've already put some effort in yourself.

Jump to Post

All 2 Replies

Sure, what do you have so far? In general, you won't get much help without showing that you've already put some effort in yourself.

The function you're looking for is called pow. It lives in <cmath>

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.