C++ Program to implement a Recursive Function
#include <iostream.h>
#include <string.h>
#include <stdlib.h>
#include <conio.h>
void recurfunc(int start,int stop,char* buff);
void main()
{ clrscr();
cout << "enter how many times to loop: ";
char buff[100];
cin >> buff;
int num;
num = atoi(buff);
if(num >= 1)
{
recurfunc(0,num," this is a recursive function");
}
else
{
cout << "sorry you didnt enter valid data" << endl;
return;
}
getch();
}
void recurfunc(int start,int stop,char* buff)
{
if(start < stop)
{
start++;
cout << "\n" << buff << "\n";
recurfunc(start,stop,buff);
}
else
{
return;
}
}
Related Posts : C++ Programs
0 comments:
Post a Comment