C Program to Calculation of One Number Raised to Another

How to write a C Program to Calculation of One Number Raised to Another in C Programming Language ?

Two numbers are entered through the keyboard. Write a program to find the value of one number raised to the power of another. 


  1. #include<stdio.h>
  2. main()
  3. {
  4. int num1, index, result, temp; /* num2=index*/
  5.  
  6. printf("Enter the number:");
  7. scanf ("%d", &num1);
  8.  
  9. printf("Enter the index:");
  10. scanf("%d", &index);
  11.  
  12. result=1;
  13. temp=1;
  14.  
  15. while(temp<=index)
  16.  
  17. {
  18. result = result*num1;
  19.  
  20. temp++;
  21.  
  22. }
  23.  
  24. printf("%d raised to %d is: %d ", num1, index, result);
  25.  
  26. }


Another C Program to Calculation of One Number Raised to Another:



  1. #include
  2.  
  3. main()
  4. {
  5. int i,n,res;
  6. printf("Enter the Num:");
  7. scanf("%d", &n);
  8. printf("Enter the index:");
  9. scanf("%d", &i);
  10. res=pow(n,i);
  11. printf("The number " %" raised to the power " %"is "%"==" %d, n,i,res );
  12. }
  13. }

C Program to Calculation of One Number Raised to Another:


  1. #include
  2. main()
  3. {
  4. int a,b,c,d;
  5. printf("Enter two numbers separated by space: ");
  6. scanf("%d%d",&a,&b);
  7. = pow(a,b);
  8. printf("The value of, %d raised to the power of %d is %d",a,b,c);
  9. }


Learn More :