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

In a switch statement, explain what will happen if a break statement is omitted?

641


what are bit fields? What is the use of bit fields in a structure declaration?

1506


What is wild pointer in c?

615


what are the 10 different models of writing an addition program in C language?

1444


Can you write the algorithm for Queue?

1558






What is call by reference in functions?

575


What is the purpose of type declarations?

683


What is a ternary operator in c?

661


shorting algorithmS

1807


which is conditional construct a) if statement b) switch statement c) while/for d) goto

743


What is pointer to pointer in c language?

600


What are the advantages of union?

633


What is the package for freshers(Non IIT) in amazon(hyderabad). And what is the same for those who are a contract employee.

3737


Tell me about low level programming languages.

649


What is sizeof in c?

577