C Program To Find The Value Of One Number Raised To The Power Of Another


♣ Try it Out ::
#include<stdio.h>
#include<conio.h>

int Power(int b, int p)
{
    if(p == 0) return(1);
    else return((Power(b, p-1))*b);
}

int main()
{
    int BaseNumber, PowerNumber;

    printf("Enter the base number: ");
    scanf("%d", &BaseNumber);
    printf("Enter the power: ");
    scanf("%d", &PowerNumber);

    printf("\nResult:\t%d ^ %d = ", BaseNumber, PowerNumber);
    printf("%d", Power(BaseNumber, PowerNumber));

    getch();
    return(0);
}

♣ Output ::
Enter the base number: 25
Enter the power: 3

Result: 25 ^ 3 = 15625

♣ Downloads ::

Comments

Popular posts from this blog

C++ :: Topological Sort Algorithm (using DFS)

How to Hack Facebook Account

C++ :: Strongly Connected Components Algorithm (SCC)