| mohamadh95 (9) | |
|
Why am I getting this error? this is the code #include <iostream> #include<math.h> using namespace std; int main(int argc, char** argv) { int c=444,k=3,l; while(k>1){ l=(c/pow(10,k-1)); cout<<l%pow(10,k); k--;} return 0; } and the error is: main.cpp:20:24: error: invalid operands of types 'int' and 'double' to binary 'operator%' I think it's from the line cout<<l%pow(10,k); | |
|
|
|
| kbw (5520) | |
|
pow() returns a double, but modulus requires an int. http://pubs.opengroup.org/onlinepubs/007908799/xsh/pow.html | |
|
|
|
| mohamadh95 (9) | |
| thank you | |
|
|
|