/*This program calculates the
power of a digit upto another user entered digit*/
#include<stdio.h>
#include<conio.h>
main()
{
int digit=1, power=1, temp=1, counter;
printf("Please enter the digit: ");
scanf("%d",&digit);
printf("now enter its power: ");
scanf("%d",&power);
temp=digit;
for(counter = 1; counter < power ; counter++ )
{
temp = temp * digit;
}
printf("%d raised to power %d answers:
%d",digit,power,temp);
getche();
}
No comments:
Post a Comment