473,396 Members | 1,963 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

what is a recrusive function

hi! can you tell me what is a recrusive function? and what it does? and there are some lines in this small program that i could not understand (followed by???????) can u plz explain me those lines? plz

Expand|Select|Wrap|Line Numbers
  1. //Program to implement a Recursive Function
  2. #include <iostream.h>
  3. #include <string.h>
  4. #include <stdlib.h>
  5. #include <conio.h>
  6. void recurfunc(int start,int stop,char* buff);
  7. void main()
  8.    {   clrscr();
  9.     cout << "enter how many times to loop: ";
  10.     char buff[100];
  11.     cin >> buff;
  12.     int num;
  13.     num = atoi(buff);//??????what atoi function does?
  14.     if(num >= 1)
  15.     { recurfunc(0,num," this is a recursive function");  }
  16.     else { cout << "sorry you didnt enter valid data" << endl;
  17.         return;   } 
  18.         getch();
  19.     }
  20.     void recurfunc(int start,int stop,char* buff) */ what is the use of start &stop variable in the program????????? /*
  21.         {    if(start < stop)
  22.                                    {                            start++;
  23.                 cout << "\n" << buff << "\n";
  24.                 recurfunc(start,stop,buff);
  25.            }
  26.             else
  27.             {      return;   }
  28.        }
Jan 31 '07 #1
2 2072
Motoma
3,237 Expert 2GB
hi! can you tell me what is a recrusive function? and what it does? and there are some lines in this small program that i could not understand (followed by???????) can u plz explain me those lines? plz

//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);//??????what atoi function does?
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) */ what is the use of start &stop variable in the program????????? /*
{ if(start < stop)
{ start++;
cout << "\n" << buff << "\n";
recurfunc(start,stop,buff);
}
else
{ return; }
}
A recursive function is a function that calls itself before completing.
atoi() takes character representation of a number, and returns it as an integer.
The function will stop calling itself when it has start is equal to stop.
Jan 31 '07 #2
RedSon
5,000 Expert 4TB
This will tell you everything you need to know. And it is probably translated into your language if you use your local wikipedia wiki.

Wikipedia
Jan 31 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
28
by: David MacQuigg | last post by:
I'm concerned that with all the focus on obj$func binding, &closures, and other not-so-pretty details of Prothon, that we are missing what is really good - the simplification of classes. There are...
37
by: Bengt Richter | last post by:
ISTM that @limited_expression_producing_function @another def func(): pass is syntactic sugar for creating a hidden list of functions. (Using '|' in place of '@' doesn't change the picture...
10
by: Brad Tilley | last post by:
Is there an easier way to do this: def print_whats_returned(function): print function print type(function)
56
by: Xah Lee | last post by:
What are OOP's Jargons and Complexities Xah Lee, 20050128 The Rise of Classes, Methods, Objects In computer languages, often a function definition looks like this: subroutine f (x1, x2, ...)...
21
by: Helge Jensen | last post by:
I've got some data that has Set structure, that is membership, insert and delete is fast (O(1), hashing). I can't find a System.Collections interface that matches the operations naturally offered...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
1
by: td0g03 | last post by:
Hello, I am new to C and I am new to English. I not sure what palindromes mean. I don't know exactly what my teacher wants me to do. If someone could explain it to me in a different way that would be...
8
by: Viktor | last post by:
Can somebody give me an explanation what happened here (or point me to some docs)? Code: HMMM = None def w(fn): print 'fn:', id(fn) HMMM = fn
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.