Pages

Monday, 10 August 2015

Calculate the Power of a Number

C Program to Calculate the Power of a Number
Coding:
#include<stdio.h>
int main()
{
    int i,x;
    float n,p;
    printf("Please enter the number:");
    scanf("%f",&n);
    printf("Please enter the power:");
    scanf("%d",&x);
    p=1;
    for(i=1;i<=x;i++)
            p=p*n;
    printf("Result is:=%f",p);
    return 0;
}

Output:
Please enter the number:4
Please enter the power:3
Result is:=64.000000