TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Power of N Number Program in C
Ashish Srivastava
Apr 03
2016
Code
659
0
0
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
expand
#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);
}
C
N Number