• Source
    1. #include <stdio.h>
    2.  
    3. unsigned int Ispower( unsigned int num , unsigned int pow )
    4. {
    5. unsigned int temp = 1;
    6. if(num == 1)
    7. return (pow == 1);
    8.  
    9. while( temp < num )
    10. {
    11. temp = temp*pow;
    12. if( temp == num )
    13. {
    14. return 1;
    15. }
    16. }
    17.  
    18. return 0;
    19.  
    20.  
    21. }
    22.  
    23. int main(void) {
    24. // your code goes here
    25. unsigned int num = 81;
    26. unsigned int pow = 9;
    27.  
    28. if( Ispower( num, pow) )
    29. {
    30. printf(" the number %d, is power of %d", num, pow );
    31. }
    32. else
    33. {
    34. printf(" the number %d, is NOT power of %d", num, pow );
    35. }
    36. return 0;
    37. }
    38.