Saturday, July 16, 2016

Program to find the value of one number raised to the power of another

Two numbers are entered through the keyboard. Write a program to find the value of one number raised to the power of another.
Let Us C Page 128 [B] (c)

/* Program to calculate the value of a number raised to another

Author : Viks Von Doom
Date : 16/07/2016 Time  : 01:56 PM*/

#include<stdio.h>
#include<math.h>

int main()
{
    int num_1, num_2, result;

    printf("Enter the first number : ");
    scanf("%d", &num_1);
    printf("Enter the second number : ");
    scanf("%d", &num_2);

    result = pow(num_1,num_2);

    printf(" The result of %d raised to %d is : %d", num_1, num_2, result);


return 0;
}
 

The program calculates the value of the first number to the power of second number and this is done with the help of pow() function from the math.h header file.  

 

No comments:

Post a Comment