Access over 20 million homework & study documents

C power

Content type
User Generated
Rating
Showing Page:
1/1
#include<stdio.h>
#include<conio.h>
int power(int,int);
void main()
{
int n,p,result;
clrscr();
printf("Enter the number");
scanf("%d",&n);
printf("\nEnter the power to be calculated");
scanf("%d",&p);
result=power(n,p);
printf("The result of %d to power %d is %d",n,p,result);
getch();
}
int power(int n,int p)
{
static int r=1;
if(p==0)
{
return(1);
}
else
{
r=r*n;
power(n,p-1);
}
return(r);
}

Sign up to view the full document!

lock_open Sign Up
Unformatted Attachment Preview
#include #include int power(int,int); void main() { int n,p,result; clrscr(); printf("Enter the number"); scanf("%d",&n); printf("\nEnter the power to be calculated"); scanf("%d",&p); result=power(n,p); printf("The result of %d to power %d is %d",n,p,result); getch(); } int power(i ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Anonymous
Really great stuff, couldn't ask for more.

Studypool
4.7
Indeed
4.5
Sitejabber
4.4