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

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can I sort a linked list?

630


What is the difference between if else and switchstatement

1308


What is the difference between new and malloc functions?

570


What is difference between structure and union with example?

586


formula to convert 2500mmh2o into m3/hr

491






Is this program statement valid? INT = 10.50;

683


Is flag a keyword in c?

673


Why static is used in c?

614


How can I invoke another program or command and trap its output?

608


GIVEN A FLOATING POINT NUMBER HOW IS IT ACTUALLY STORED IN MEMORY ? CAN ANYONE EXPLAIN?? THE 32 BIT REPRESENTATION OF A FLOATING POINT NUMBER ALLOTS: 1 BIT-SIGN 8 BITS-EXPONENT 23 BITS-MANTISSA

1422


Is r written in c?

720


What is %g in c?

608


how to execute a program using if else condition and the output should enter number and the number is odd only...

1648


Explain how can I make sure that my program is the only one accessing a file?

614


what is the height of tree if leaf node is at level 3. please explain

1591