Data Structure Programs
|
Program to make a recursive program of finding the
power of a number. |
#include<iostream.h>
#include<conio.h>
int rec(int,int);
void main()
{
clrscr();
long int y,x,p;
cout<<"\n Enter the no.:";
cin>>x;
cout<<"\n Enter the power of no.:";
cin>>y;
p=rec(x,y) ;
cout<<"\n The answer is :"<<p;
getch();
}
int rec(int x,int y)
{
int q;
if(y==0)
{
return 1;
}
else
{
q=x*rec(x,(y-1));
}
return q;
}
|
Output: |

If any
of you want to submit your programs and
contribute to site please mail us at:
citysuvidha@gmail.com
Click here to have a look at List of programs
You can download all the programs in a zip file also. For this you have to do one thing. Just register at the citysuvidha forum and start any thread of any topic. Once you start the thread and put your request, admin will automatically send you the desired zip file.