Wednesday, 3 October 2018

Raising a number to larger power

#include<stdio.h>
#include<conio.h>
void main()
{
    int a,b,i,power;
    power=1;
    printf("\n Enter a number");
    scanf("%d",&a);
    printf("\n Enter required power");
    scanf("%d",&b);
    i=1;
    while(i<=b)
    {
power=power*a;
i=i+1;
    }
    printf("%d to the power of %d is = %d\n",a,b,power);
    getch();
}

No comments:

Post a Comment