Create pow(m,n) function which return values for negative number.


 #include<stdio.h>

float pow(int m,int n)

{

    int i=1;

float result=1.0;

if(n<0)

{

while(n!=0)

{

result=result*(1.0/m);

n++;

}


}

else

{

if (n=0)

    result=1;

    else

    while(i<=0)

    {

    result=result*m;

    i++;

}

}

    return result;

}

void main()

{

int base,po;

float result;


printf("Enter the value of base and power");

scanf("%d %d",&base,&po);

result=pow(base,po);

printf("%f",result);

}



Output is:-


Top Keywords:-
  • C program to return values for negative number

Post a Comment

0 Comments