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
Difference between constant pointer and pointer to a constant.
When we use void main and int main?
What is const keyword in c?
What does void main () mean?
How do you use a 'Local Block'?
What are the types of variables in c?
what type of questions arrive in interview over c programming?
What is difference between structure and union?
What is a program?
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
Write a program to implement queue.
What is data structure in c language?
define string ?
How do you define structure?
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.