Math Power C++ Code



Simple Math Power Program


here is the code:

#include<iostream.h>
#include<conio.h>
#include<stdio.h>

float power(float a,float b)
{
            float c,d;
            d=a;
            
            for (c=1;c<b;c++)
            {
            a=a*d;
            }
            return(a);

}

main()
{
      float a,b;
      cout<<"Enter the number = ";cin>>a;
      cout<<"\nEnter the power  = ";cin>>b;
      cout<<"The answer is = "<<power(a,b)<<endl;
      system("pause");
}


0 komentar:

Posting Komentar