C++ program to use function for y=m^n

//C++ program to use function for y=m^n
#include <iostream>
using namespace std;
float evaluate(float m,int n)
{
    int i=n;
    float y=1;
    while(i!=0)
    {
        y=y*m;
        i--;
    }
    return y;
}
int main()
{
    float m,y;
    int n;
    cout<<"Enter base and power: ";
    cin>>m>>n;
    y=evaluate(m,n);
    cout<<"Evaluated value is "<<y;
    return 0;
}

No comments:

Post a Comment