Function with a exponent -help

Problem: write a function named powfun() that raises an integer number passed to it to a positive integer power and displays the result. The positive integer should be the second value passed to the function. Declare the variable used to store the result as a long integer data type to ensure sufficient storage fo rthe result. My interpretation program of this problem is as follows;

[#include <iostream>
using namespace std;



int Powfun(long int);



int main ()
{
int value = 0;
long int x = 2*exp((.02*(4)));


if (value <= 0);
else
value = x;


return (x);


cout << " the exponent value of " << x
<< "is " << x << endl;


cin.ignore();

return 0;
}

int Powfun(long int x);




]

please help because this program is receiving build errors and I do not know for sure if I have the right code to address the problem
I think the problem wants you to write a function named powfun that actually does something. What you did was to let the main function do all the work.

here are my observations
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>
//forgot to include cmath
using namespace std;

int Powfun(long int);   //read the problem, it states: The positive integer should be the
                        //second value passed to the function.

int main ()
{
    int value = 0;
    long int x = 2*exp((.02*(4)));  //exp is not the function to use the problem asks that
                                    //you throw two arguments to the function. I suggest
                                    //reading about the pow() function.

    if (value <= 0);
    else
    value = x;

    return (x);         //main will exit here.

    cout << " the exponent value of " << x  //This section of the code is unreacheable
    << "is " << x << endl;

    cin.ignore();

    return 0;
}

int Powfun(long int x);     //another prototype? You'll need to implement the function here. 
Topic archived. No new replies allowed.