Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't understand error in this program for checking automorphic no.?

Tags:

c++

c

int a = 0, b, c, e, n = 25;
e = n;

while(n!=0)
{
  n=n/10;
  a++;
}

printf("%d",a);

b = e * e;
c = b % (pow(10, a));
if(c==e)
  printf("automorphic");

For the line

c=b%(pow(10,a)); 

the compiler shows an error:

invalid operands of types `int' and `double' to binary `operator%' 
like image 383
Krishna_Pedaprolu Avatar asked Feb 22 '26 01:02

Krishna_Pedaprolu


1 Answers

pow returns a double, and you can't use % on doubles.

like image 159
MTilsted Avatar answered Feb 23 '26 13:02

MTilsted