• Source
    1. #include<stdio.h>
    2.  
    3. /* Function to calculate x raised to the power y */
    4. int power(int x, unsigned int y)
    5. {
    6. if (y == 0)
    7. return 1;
    8. else if (y%2 == 0)
    9. return power(x, y/2)*power(x, y/2);
    10. else
    11. return x*power(x, y/2)*power(x, y/2);
    12. }
    13.  
    14. /* Program to test function power */
    15. int main()
    16. {
    17. int x = 2;
    18. unsigned int y = 3;
    19.  
    20. printf("%d", power(x, y));
    21. return 0;
    22. }