Pages

Thursday, 8 February 2018

Two numbers are entered through the keyboard. Write a 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.

Ans.

#include<stdio.h>
#include<conio.h>
void main()
{
    clrscr();
    int num1, num2, i, ans=1;
    printf("enter any two numbers ");
    scanf("%d%d",&num1,&num2);
    // we wanted to find out num1 raised to num2
    for(i=1;i<=num2;i++)
    {
        ans=ans*num1;
    }
    printf("Answer is %d",ans);
    getch();
}