what is wrong with this code?

int myFunction(int b)
{
int c;
double z = b;
double d;
int y=0;
while (d<0)
{
d= (z/pow(10,y));
c = (int)d;
c = c%10;
if (!(c=1))
++y;
else
b=0;
}
return b;
}

The compiler gets 3 erros of the pow():

- math.h(575): could be 'long double pow(long double,int)'
- math.h(527): or 'float pow(float,int)'
- math.h(489): or 'double pow(double,int)'

thx
Mandana

Use code tags, please read this

And now to solve your problem:

Pow() wants 2 doubles as parameters, but y is declared as an int.
So change int y to double y and you're on the roll!

int myFunction(int b)

You might want to change this in double myFunction(double b) because you assign the value of b to a double (z) in your code : double z = b

Be a part of the DaniWeb community

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