Finding nth power of integer m through C program : C program to find nth power of integer m.
Input:
m=3 n=2
output:
9.000
---------END OF QUESTION---------------------

The question seems simple but i need to satisfy these additional test case as well.

1)For negative M

Input : -2  3
output : -8.000

2)For negative N

Input : 2  -3
output : 0.125000

3)For negative M and N

Input : -2  -3
output : -0.125000

However my below programs doesn't give correct output.

void main()

{
    
    signed int m, n;

    int i;

    float p;

    clrscr();

    printf("Enter the number and its power (exponent)\n");

    scanf("%d%d",&m,&n);

    p=1;

    if (n==0)

    {

	printf("%d raised to %d is: %f",m,n,p);

    }

    if (n>0)

    {

	for( i = 0 ; i < n ; i++ )

	p*=m;

	if(m>0)

	printf("%d raised to %d is: %f",m,n,p);

	if(m<0)

	printf("%d raised to %d is: %f",m,n,-p);

    }

    if (n<0)

    {

	n=-n;

	for( i = 0 ; i < n ; i++ )

	p*=m;

	if(m>0)

	printf("%d raised to %d is: %f",m,-n,1/p);

	if(m<0)

	printf("%d raised to %d is: %f",m,-n,-(1/p));

    }

getch();

}

Can u kindly provide the correct program for the test cases?

Also i cant declare signed float as it gives an error.
