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
When do we get logical errors?
Explain what is gets() function?
What is strcpy() function?
What is 1d array in c?
Write a program to know whether the input number is an armstrong number.
What are valid signatures for the Main function?
What is string in c language?
write a program to display all prime numbers
difference between object file and executable file
What is echo in c programming?
Are the expressions * ptr ++ and ++ * ptr same?
If errno contains a nonzero number, is there an error?
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); }
ATM machine and railway reservation class/object diagram
What is a file descriptor in c?