SCHOOL OF CODE BUILDERS
Learn To CODE. Become A DEVELOPER.
Pages
HOME
DATA STRUCTURES
STRINGS
ARRAYS
MATRIX
BINARY TREES
LINKED LIST
STACK
QUEUE
SORTING
SEARCHING
C
PYTHON
PSEUDOCODE
CONTEST PROBLEMS
ALGORITHMS
PATTERNS
PHP
C PUZZLES
C INTERVIEW QUESTIONS
JAVA
C++
HASHING
RECURSION
BASIC C PROGRAMS
TCS-CODEVITA
FACEBOOK
CONTACT US
C program to find factorial of a number using user-defined function
C program to find factorial of a number using user-defined function
Output:
Enter a number to get its factorial:
5
The factorial of 5 is 120
Implementation:
#include
int findfact(int n) { int fact=1; while(n) { fact *= n; n--; } return fact; } int main(void) { int n; printf("Enter a number to get its factorial:\n"); scanf("%d",&n); printf("The factorial of %d is %d",n,findfact(n)); return 0; }
PREVIOUS
NEXT
HOME