473,414 Members | 1,888 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,414 software developers and data experts.

can function call it self then how explain

can function call it self then how explain
Jan 21 '12 #1
2 2254
C CSR
144 100+
Yes. Its called "Recursion," and if you don't have a way to end it you will crash--loops until your out of memory. I'd give you an example but you didn't say what language you're using.
Jan 21 '12 #2
C CSR
144 100+
Here's a basic example I snatched from a helpfile in MSAccess. Just adapt the concept to your code. Watch the output; it climbs up through the repeated function calls, then backs back down when it hits a certain condition. Step through it to fully understand the action & results of your variables.

Expand|Select|Wrap|Line Numbers
  1. Function Factorial(N)
  2.     If N <= 1 Then    ' Reached end of recursive calls.
  3.         Factorial = 1    ' (N = 0) so climb back out of calls.
  4.     Else    ' Call Factorial again if N > 0.
  5.         Debug.Print "FuncN =" & N
  6.         Factorial = Factorial(N - 1) * N
  7.     End If
  8. End Function
  9.  
Jan 21 '12 #3

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

Similar topics

0
by: Sylwia | last post by:
Hi! I have implemented a Python services. It behaves as a supervisor for log files. If the space used by log files is bigger than a given upper limit, then it starts to delete log files until...
4
by: mangi03 | last post by:
Hi, I came acrosss g++ compile errors whenever I make a function call by reference and found out from the test program that compiler is treating the function argument differently when another...
30
by: bnp | last post by:
Hi, Is possible to use functions in conditional operator as ashown below. ..... ..... int fun1() { // body }
6
by: Upendra | last post by:
Can any body explain me about the exact sequence of operations that takes place when a function call takes place. Consider all cases like functions with no return values and one or more retun...
13
by: Bern McCarty | last post by:
I have run an experiment to try to learn some things about floating point performance in managed C++. I am using Visual Studio 2003. I was hoping to get a feel for whether or not it would make...
20
by: sam_cit | last post by:
Hi Everyone, I have the following code, int main() { int p = {10,20,30,40,50}; int *i = &p; printf("before : %p\n",(void*)i); printf("1 %d %d\n",*++i,*i++);
1
by: ashish | last post by:
Hi All, I wanted to know how to handle events like 'logoff' in the main thread so that any process which is being run by svcDoRun method of service does not get 'interrupted function call'...
1
by: Brownie Guy | last post by:
Today while researching a bug I found this script: var Event = { add: function() { if (window.attachEvent) { return function(el, type, fn) { var f = function() { fn.call(Dom.get(el),...
1
by: news.microsoft.com | last post by:
I am getting the following error on the return from a function call.It specically happens on the assignment of the return value from the function call. No error happens inside the function. The...
21
by: coolguyaroundyou | last post by:
See the below code: void func(int x) { printf("%d",x); } int main() { int j=0;
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.