write a program that finds the factorial of a number using
recursion?
Answers were Sorted based on User's Feedback
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
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 |
Do you have any idea about the use of "auto" keyword?
the 'sizeof' operator reported a larger size than the calculated size for a structure type. What could be the reason?
What is the equivalent code of the following statement in WHILE LOOP format?
Is there any restriction in how many arguments printf or scanf function can take? in which file in my c++ compiler i can see the code for implementation of these two functions??
What is the difference between array and linked list in c?
What are header files and explain what are its uses in c programming?
main() { int i; printf("%d", &i)+1; scanf("%d", i)-1; }
what is the difference between getch() and getche()?
How many types of operators are there in c?
What are the main characteristics of c language describe the structure of ac program?
Which is the memory area not included in C program? give the reason
simple program for virtual function?