i am using code block for learning c. my code is
#include
#include
int main()
{
int x;
x = pow(5,2);
printf(\"%d\", x);
}
Out
Try changing initialization to this:
int x=-1 ,i=-1 ,j=-1;
And last print to this:
printf("pow(%d, %d) == %d\n", i, j, x);
That should give good hint about the problem. Also, check return values of scanf
, they should return number of items read, ie. 1 with code above.
It's almost certain, that you entered invalid input for scanf, and i
or j
were left uninitialized, and that 24 is just garbage value.
Also, compile with warnings enabled, and fix them (like, add return 0;
to end of main
).