Logo 
Search:

C Programming Articles

Submit Article
Home » Articles » C Programming » Homework HelpRSS Feeds

Program of finding factorial recursively

Posted By: Reinhart Fischer     Category: C Programming     Views: 4124

Write a program of finding factorial recursively.

Code for Program of finding factorial recursively in C Programming

#include <stdio.h>
int fact(int n);
long  old=0;    \\E
long current=0;    \\F
main()
{
 int k = 4,i;
 long diff;
 i =fact(k);
 printf("The value of i is %d\n",i);
 diff = old-current;
 printf("stack overheads are %16lu\n",diff);
}
int fact(int n)
{
int j;
staticint m=0;
if(m==0) old =(long) &j;    \\A
if(m==1) current =(long) &j;    \\B
m++;        \\C
printf("the address of j and m is  %16lu %16lu\n",&j,&m);    \\D
if(n<=0)
return(1);
elsereturn(n*fact(n-1));
}
  
Share: 


Didn't find what you were looking for? Find more on Program of finding factorial recursively Or get search suggestion and latest updates.

Reinhart Fischer
Reinhart Fischer author of Program of finding factorial recursively is from Frankfurt, Germany.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!