write a program that finds the factorial of a number using
recursion?
Answer Posted / 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 |
Post New Answer View All Answers
Is boolean a datatype in c?
Which header file is essential for using strcmp function?
When should the volatile modifier be used?
Can you think of a logic behind the game minesweeper.
What does stand for?
main() { struct s1 { char *str; struct s1 *ptr; }; static struct s1 arr[] = { {"Hyderabad",arr+1}, {"Bangalore",arr+2}, {"Delhi",arr} }; struct s1 *p[3]; int i; < BR> for(i=0;i<=2;i++) p[i] = arr[i].ptr; printf("%s ",(*p)->str); printf("%s ",(++*p)->str); printf("%s ",((*p)++)->str); }
Why doesnt the call scanf work?
Explain how does free() know explain how much memory to release?
What does static variable mean in c?
What is c variable?
Explain c preprocessor?
What is the best way to comment out a section of code that contains comments?
What is the explanation for the dangling pointer in c?
What is the difference between variable declaration and variable definition in c?
Hai what is the different types of versions and their differences