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

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



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Difference between constant pointer and pointer to a constant.

613


When we use void main and int main?

588


What is const keyword in c?

750


What does void main () mean?

734


How do you use a 'Local Block'?

724






What are the types of variables in c?

582


what type of questions arrive in interview over c programming?

1559


What is difference between structure and union?

601


What is a program?

666


a) Identify the following declarations. Ex. int i (integer variable) float a[l0](array of 10 real nos) int (*f())() void *f int (*f()) [] void *f int f[] [] [] char *(*f) () int (*f[]) [] float(*f) [] [] float **f int ******f

1587


Write a program to implement queue.

666


What is data structure in c language?

607


define string ?

669


How do you define structure?

567


Write a program to replace n bits from the position p of the bit representation of an inputted character x with the one's complement. Method invertBit takes 3 parameters x as input character, p as position and n as the number of positions from p. Replace n bits from pth position in 8 bit character x. Then return the characters by inverting the bits.

3691