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!
download android app

Popular C Examples









codesadda.com

Codesadda.com is your home of programming solutions, tutorials, video tutorials and much more. Sign Up for our weekly newsletter to get update about new content.

Like us on Facebook | Connect with us on LinkedIn | Subscribe our Channel on Youtube