write a program that finds the factorial of a number using
recursion?
Answer Posted / abhinandan
#include<stdio.h>
main()
{
int a, fact;
printf("\nEnter any number: ");
scanf ("%d", &a);
fact=rec (a);
printf("\nFactorial Value = %d", fact);
}
rec (int x)
{
int f;
if (x==1)
return (1);
else
f=x*rec(x-1);
return (f);
}
| Is This Answer Correct ? | 2 Yes | 1 No |
Post New Answer View All Answers
Write programs for String Reversal & Palindrome check
C language questions for civil engineering
Write a C program on Centralized OLTP, Decentralized OLTP using locking mechanism, Semaphore using locking mechanism, Shared memory, message queues, channel of communication, sockets and a simple program on Saving bank application program using OLTP in IPC?
Write a program to print ASCII code for a given digit.
How do we print only part of a string in c?
Can you add pointers together? Why would you?
Why does everyone say not to use gets?
What is the stack in c?
What is the best style for code layout in c?
Why we not create function inside function.
What tq means in chat?
Can I use base-2 constants (something like 0b101010)? Is there a printf format for binary?
Can include files be nested?
What are the applications of c language?
If a variable is a pointer to a structure, then which operator is used to access data members of the structure through the pointer variable?