i dont get why it says error

Get two numbers n and m, and then calculate the nth power of m.

Input specification
There will be two numbers in the input file which are between 1 < n, m ≤ 9.
Output specification
Calculate and show the result followed by an endline.




#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
int m,n,sum;
scanf("%d %d",&m,&n);
sum=pow(n,m);
printf("%d",sum);

return 0;
}
closed account (E0p9LyTq)
What is the error you are getting?

I get warnings only if I use Visual Studio 2015 Community, and no warnings if I use TDM-GCC 4.9.2.

The source code compiles even with warnings.
it says failed test case 8
The problem description refers to 'numbers'. It doesn't say whether they are integer or floating point types. Do you know what the actual input numbers will be?

The description also says, "show the result followed by an endline". The newline is missing in the above code.

Last edited on
can I solve this with loop
can I solve this with loop

If you are sure that n will be an integer, yes.
Also, check that you have m and n the right way round in this statement:

sum=pow(n,m);
That will calculate nm
The question says "calculate the nth power of m", i.e. mn

http://www.cplusplus.com/reference/cmath/pow/
Last edited on
Topic archived. No new replies allowed.