Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

write a program that finds the factorial of a number using
recursion?

Answer Posted / harsha

#include<stdio.h>
#inlcude<conio.h>
unsigned int recr_factorial(int n);
unsigned int iter_factorial(int n);
void main()
{
int n,i;
long fact;
clrscr();
printf("Enter the number:");
scanf("%d",&n);
if(n==0)
printf("Factorial of 0 is 1\n");
else
{
printf("Factorial of %d Using Recursive Function is %d\n",n,recr_factorial(n));
printf("Factorial of %d Using Recursive Function is %d\n",n,iter_factorial(n));
}
getch();
}
/*Recursive Function*/
unsigned int recr_factorial(int n);
{
return n>=1 ? n*recr_factorial(n-1):1;
}
/*Non-Recursive Function*/
unsigned int iter_Function(int n)
{
int accu=1;
int i;
for(i=1;i<=n;i++)
{
acc * =i;
}
return acc;

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is there any data type in c with variable size?

1045


Why do we need arrays in c?

1094


Q.1 write aprogram to stack using linklist o insert 40 items? Q.2 write a program to implement circular queue with help of linklist?

2058


What is string in c language?

1087


How do I get a null pointer in my programs?

1068


How do I convert a string to all upper or lower case?

1063


hi send me sample aptitude papers of cts?

2113


What is variable initialization and why is it important?

1181


Write a program to implement a round robin scheduler and calculate the average waiting time.Arrival time, burst time, time quantum, and no. of processes should be the inputs.

1058


What is pass by reference in functions?

787


Write a program to print numbers from 1 to 100 without using loop in c?

1037


What are the two types of structure?

1046


Process by which one bit pattern in to another by bit wise operation is?

1117


Write a program that accept anumber in words

1717


Explain how can you avoid including a header more than once?

1049