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.- #include<stdio.h>
- main()
- {
- int num1, index, result, temp; /* num2=index*/
- printf("Enter the number:");
- scanf ("%d", &num1);
- printf("Enter the index:");
- scanf("%d", &index);
- result=1;
- temp=1;
- while(temp<=index)
- {
- result = result*num1;
- temp++;
- }
- printf("%d raised to %d is: %d ", num1, index, result);
- }
Another C Program to Calculation of One Number Raised to Another:
- #include
- main()
- {
- int i,n,res;
- printf("Enter the Num:");
- scanf("%d", &n);
- printf("Enter the index:");
- scanf("%d", &i);
- res=pow(n,i);
- printf("The number " %d " raised to the power " %d "is "%d "==" %d, n,i,res );
- }
- }
C Program to Calculation of One Number Raised to Another:
- #include
- main()
- {
- int a,b,c,d;
- printf("Enter two numbers separated by space: ");
- scanf("%d%d",&a,&b);
- c = pow(a,b);
- printf("The value of, %d raised to the power of %d is %d",a,b,c);
- }