1: #include <stdio.h>
2: long factorial(int n)
3: {
4: if(n ==0)
5: {
6: return 1;
7: }
8: return (n * factorial(n-1));
9: }
10: main()
11: {
12: int n;
13: long fact = 0;
14: printf("Enter a Number : ");
15: scanf("%d",&n);
16: fact = factorial(n);
17: printf("Result = %ld\n",fact);
18: }
RTOS, Linux Kernel internal, OS-Programming C & Data Structures, Debugging, Optimizations, Makefiles and Wireless Technologies (Wi-Fi ,LTE and LTE-Advanced )
Search This Blog
Friday, October 30, 2015
Factorial of number in C.
Labels:
C
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment