fork download
  1. #include <stdio.h>
  2.  
  3. int power(int a,int b){
  4. int x=1;
  5. for(int i=1;i<=b;i++){
  6. x=x*a;
  7. }
  8. return x;
  9. }
  10.  
  11. int main() {
  12. int a;
  13. printf("Enter the base: \n");
  14. scanf("%d",&a);
  15. int b;
  16. printf("Enter the power: \n");
  17. scanf("%d",&b);
  18. int p=power(a,b);
  19. printf("%d raised to power %d is %d",a,b,p);
  20. return 0;
  21. }
Success #stdin #stdout 0s 5320KB
stdin
2
3
stdout
Enter the base: 
Enter the power: 
2 raised to power 3 is 8