plz answer..... a program that reads non-negative integer
and computes and prints its factorial
Answer Posted / valli
//using recursion
fact(int);
main()
{
int n;
printf("enter n");
scanf("%d",n)
if(n<0)
printf("invalid number");
else
printf("factorial of %d =%d",n,fact(n));
}
fact(int n)
{
if(n==0||n==1)
return 1;
else
return n*fact(n-1);
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
How to implement a packet in C
Write a c program to demonstrate character and string constants?
How is a macro different from a function?
What is local and global variable in c?
Explain the difference between the local variable and global variable in c?
What are header files in c?
Which function in C can be used to append a string to another string?
What is a double c?
Explain how do you use a pointer to a function?
how to print the character with maximum occurence and print that number of occurence too in a string given ?
Difference between strcpy() and memcpy() function?
What does calloc stand for?
Should I learn c before c++?
What is %s and %d in c?
Apart from dennis ritchie who the other person who contributed in design of c language.