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

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

Is This Answer Correct ?    197 Yes 32 No

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

Answer / inderjeet

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

Is This Answer Correct ?    62 Yes 18 No

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

Answer / bala c king

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

Is This Answer Correct ?    35 Yes 14 No

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

Answer / asit kumar swain

#include<stdio.h>
#include<conio.h>
int fact(int);
void main()
{
int num,fact1;
clrscr();
printf("Enter a value of num");
scanf("%d",&num);
fact1=fact(num);
printf("factorial=%d",fact1);
}
int fact(int n)
{
if(n==0)
{
return 1;
}
else
{
return n*fact(n-1);
}
}

Is This Answer Correct ?    27 Yes 13 No

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

Answer / sheenu singla

//program to find the factorial of a number
#include<stdio.h>
#include<conio.h>
void main()
{
int a,fact=1;
for(a=1;a<=5;a++)
fact=fact*a;
}
printf("%d",fact);
getch();
}

Is This Answer Correct ?    18 Yes 4 No

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

Answer / meenakshi

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

Is This Answer Correct ?    17 Yes 8 No

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

Answer / bhargav

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

Is This Answer Correct ?    13 Yes 4 No

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

Answer / danish

>
#include<conio.h>
int fact(int);
void main()
{
int num,fact1;
clrscr();
printf("Enter a value of num");
scanf("%d",&num);
fact1=fact(num);
printf("factorial=%d",fact1);
}
int fact(int n)
{
if(n==0)
{
return 1;
}
else
{
return

Is This Answer Correct ?    13 Yes 8 No

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

Answer / prasenjit banik

#include<iostream.h>
#include<conio.h>
void main()
{
int n,fact;
int rec(int); clrscr();
cout<<"Enter the number:->";
cin>>n;
fact=rec(n);
cout<<endl<<"Factorial Result are:: "<<fact<<endl;
getch();
}
rec(int x)
{
int f;
if(x==1)
return(x);
else
{
f=x*rec(x-1);
return(f);
}
}

Is This Answer Correct ?    14 Yes 9 No

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

Answer / sibnath halder

//*write a c program to calculate factorial by using
recursion*//
#include<stdio.h>
void main()
{
int factorial(int);
int n;
printf("Enter a number: ");
scanf("%d",&n);
printf("Factorial of %d is: %d",n,factorial(n));
}
int factorial(int f)
{
int fact;
if(f==1)
return(1);
else
fact=f*factorial(f-1);
return(fact);
}

Is This Answer Correct ?    10 Yes 5 No

Post New Answer

More C Interview Questions

write a program to display & create a rational number

1 Answers   HCL, TCS,


What is true about the following C Functions a.Need not return any value b.Should always return an integer c.Should always return a float d.Should always return more than one value.

11 Answers   TCS,


Under what circumstances does a name clash occur?

0 Answers   InterGraph,


Explain how does flowchart help in writing a program?

0 Answers  


main(){char *str;scanf("%s",str);printf("%s",str); }The error in the above program is: a) Variable 'str' is not initialised b) Format control for a string is not %s c) Parameter to scanf is passed by value. It should be an address d) none

0 Answers  






with out using main how to execute the program?

2 Answers  


int a[3][5]={ {1,2,3,4,5],{2,3,4,5,6},{10,11,12,13,14}}; int *p=&a; printf(ā€œ%dā€,*(*(x+1)+3));

2 Answers   Wipro,


Why we use void main in c?

0 Answers  


What are multidimensional arrays?

0 Answers  


write a string copy function routine?

2 Answers  


control 50 devices which has 2 states on and off.using bitwise operator.plz answer it its urgent

1 Answers  


What are the types of operators in c?

0 Answers  


Categories