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?

Answers were Sorted based on User's Feedback



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

Answer / abhinandan

#include<stdio.h>

main()

{

int a, fact;



printf("\nEnter any number: ");

scanf ("%d", &a);



fact=rec (a);

printf("\nFactorial Value = %d", fact);



}


rec (int x)

{

int f;



if (x==1)

return (1);

else

f=x*rec(x-1);



return (f);

}

Is This Answer Correct ?    2 Yes 1 No

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

Answer / 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

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

Answer / priyanka

# include <stdio.h>
main()
{
int n,f,fact;
clrscr();
printf("Enter a no.....");
scanf("%d",&n);
f=fact(n);
printf("Factorial is :%d",f);
}
int fact(int n)
{
if(n<=1)
return 1;
else
n=n*fact(n-1);
return n;
}
getch();

Is This Answer Correct ?    0 Yes 1 No

Post New Answer

More C Interview Questions

enum colors {BLACK,BLUE,GREEN} main() { printf("%d..%d..%d",BLACK,BLUE,GREEN); return(1); }

4 Answers   ME,


What are different types of variables in c?

0 Answers  


Can U write a C-program to print the size of a data type without using the sizeof() operator? Explain how it works inside ?

3 Answers   HCL, TCS,


What are pointers in C? Give an example where to illustrate their significance.

0 Answers   Wipro,


Can you please explain the difference between exit() and _exit() function?

0 Answers  


write a c program to find biggest of 3 number without relational operator?

12 Answers   TCS, Wipro,


i have a written test for microland please give me test pattern

0 Answers   Microland,


write a c program to find the largest and 2nd largest numbers from the given n numbers without using arrays

0 Answers   IBM,


how many times does the loop iterated ? for (i=0;i=10;i+=2) printf("Hi\n");

9 Answers   TCS,


What is c language used for?

0 Answers  


Write a program in c using only loops to print * * * * * *******

2 Answers   IBM,


what is the associativity of bitwise OR operator?

1 Answers  


Categories