In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers less than or equal to n. For example,
6!=6*5*4*3*2*1
- C code for finding the factorial is:-
- /*Write A program to calculate factorial
- */
- #include<stdio.h>
- #include<conio.h>
- void main()
- {
- int n,fact=1;
- clrscr();
- printf("Enter any Number:\n\n");
- scanf("%d",&n);
- while(n>1)
- {
- fact=fact*n;
- n-;
- }
- printf("\nFactorial is=%d",fact);
- getch();
- }
- Click here to download C code
No comments:
Post a Comment