This is in C, programe to calculate raise to Power please help the error are

//this program is calculate raise to the power
#include <iostream.h>

//Function declaration
double raiseToPow(double, int)

main()
{
double x;
int i;
cout<<"Please enter the number : ";//user prompt to enter the number
cin>>x;
cout<<"Please enter the integer power that you want this number raise to power : ";// user prompt to enter the power times
cin>>i;
cout<<x <<" raise to power " <<i <<"is = " << raiseToPow(x,i);//result
}

//function to calculate the power of some number
double raiseToPow(double x, int power)
{
double result = 1.0;//declare variable and initialize it
int i;
for(i = 0; i < power; i++)//calculate the raise to power
{
result *=x;//same as result = result*x
}
return(result);
}
Last edited on
1
2
3
4
5
6
7
8
<iostream> //not iostream.h
using namespace std; // so then you dont have to type "std::..."
...

void main()


If it's meant to be in C, you shouldn't be using C++. Which means you need to remove iostream, cout and cin.

Are you sure you want to use C?
Topic archived. No new replies allowed.