473,839 Members | 1,476 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

stack operation for recurssive factorial function

40 New Member
Hello everybody...


I want to know stack operation for recurssive factorilal function..... Means how it exactly returns value and over all calcultion will be carried out...

Plz let me know...

Thank you,
Manjiri
Feb 1 '07 #1
3 1993
Ganon11
3,652 Recognized Expert Specialist
It depends on your factorial function. If you post the code you are trying to analyze, we can try to explain what's happening.
Feb 1 '07 #2
hirak1984
316 Contributor
first make your question clear,preferabl y with a sample code.
Feb 1 '07 #3
Manjiri
40 New Member
It depends on your factorial function. If you post the code you are trying to analyze, we can try to explain what's happening.


well friends I am talking about any function which calculates the factorail of given number recursively...

Any way here is my code... Plz see and exlpain....

Expand|Select|Wrap|Line Numbers
  1. #include<stdio.h>
  2. int fact(int);
  3. int main()
  4. {
  5. int f,n;
  6. printf("Enter the number whose factorial you want to find..\n");
  7. scanf("%d",&n);
  8. f=fact(n);
  9. printf("Factorial of given number is %d\n",f);
  10. return 0;
  11. }
  12.  
  13. int fact(int n)
  14. {
  15. int f;
  16. if(n==0)
  17. return(1);
  18. else
  19. return(fact(n-1)*n);
  20. }
Feb 2 '07 #4

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

Similar topics

21
3053
by: puzzlecracker | last post by:
Guys - Is it possible to find which way system stack grows? Perhaps, I am not precise enough: When a function is called, the return address of (callee) function is put on the stack. Thus, the question is the direction where that stack heading (address increasing or decreasing). How would you implement this in cpp? any suggestion.
33
9959
by: patrick_woflian | last post by:
hey guys, im just writing a basic calculation at the moment, before building on it for an A-Level piece of work. i can add/divide etc... two numbers together yet i am having a major problem with the following calculation: z = x! / (x- y)! The following code is my attempt and i was hoping for a point in the right direction as too where i am going wrong.. cheers
35
3991
by: aNt17017 | last post by:
This is my code: long fact(int n) { if (n == 0) return(1); if(n > 100) { printf("\t\tERROR: %d is too large for factorial.\n", n); return 1;
1
1666
by: Manjiri | last post by:
Hello everybody... I want to know stack operation for recurssive factorilal function..... Means how it exactly returns value and over all calcultion will be carried out...U can follow the below code and explain... #include<stdio.h> int fact(int); int main() { int f,n;
1
2057
by: Prabu | last post by:
Hi, I have a web site hosted on a W2k3 machine with IIS 6.0 installed. When ever i run a specific task from this website I get a 'The XSL processor stack has overflowed - probable cause is infinite template recursion' error message. I created a windows application with the same code and kicked of the transformation it worked fine. This makes me believe that there is some setting in the application pool's memory which can be tweeked to...
59
55777
by: Umesh | last post by:
i wrote the following program to calculate factorial: #include<stdio.h> #include<iostream.h> void main() { int i,n; long int p=1; // or long double p=1; for exponential result which I don't want. cout<<"Enter No. ";
3
8024
by: Sugandh Jain | last post by:
Hi. How to write a function that will return me the factorial (say in a string) for the any positive integer it takes? When we find a factorial of even say 2000 or a higher number, it will be very big to be accomodated in int or long datatype. Regards, Sugandh
0
12320
kadghar
by: kadghar | last post by:
Hi, I saw that Killer posted a simple Factorial Function that allows you to calculate up to 13!, well, you can use this for bigger numbers by changing the variable type. Why is this? You can use factorial on integers (that should be the input), the output could be a string or a double, anyway you will alwas have the factorial. The only restriction is in the input. Yes, i mean this function works fine for values up to 170! or something...
4
1478
by: ssecorp | last post by:
http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/496691 so I try it and when I run: @Decorators.tail_recursion def fibtr(n): def fibt(a, b, n): if n <= 1: return b else: return fibt(b, a + b, n - 1)
0
9697
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10907
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10586
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10293
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9426
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 project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5866
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4484
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4064
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3133
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.