Want to become a Vibe Coder? Join Vibe Coding Training here
x
C# Corner
Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Refer
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Power of N Number Program in C
WhatsApp
Ashish Srivastava
Apr 03
2016
693
0
0
#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);
}
N Number
C
Up Next
Power of N Number Program in C