C Program to Find Power of a Number



Multiplying the base into exponent times gives you the value of power.



  1. //C program to find power
  2. #include<stdio.h>
  3. int main()
  4. {
  5. int b,expo;
  6. long long p = 1;
  7. int i;
  8. /* Input base and exponent from user */
  9. printf("Enter base: ");
  10. scanf("%d", &b);
  11. printf("Enter exponent: ");
  12. scanf("%d", &expo);
  13. /* Multiply base, exponent times*/
  14. for(i=1; i<=expo; i++)
  15. {
  16. p = p * b;
  17. }
  18. printf("%d ^ %d = %d", b, expo, p);
  19. return 0;
  20. }

Output


Output!