# Program to calculate Factorial of a given number

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
#include<stdio.h> #include<conio.h> void main() { int num, fact = 1; clrscr(); /*Accept a number from the user*/ printf("\nEnter the number: "); scanf("%d", &num); /*Calculate the factorial*/ for(int i=1; i<=num; i++) { fact = fact * i; } /*Display the result*/ printf("The factorial of %d is %d", num, fact); getch(); } |

**Output:**

1 2 |
Enter the number: 5 The factorial of 5 is 120 |

void main(){

int n,s=1;

printf(“enter the nth value”);

scanf(“%d”,&n);

while(n>0)

{

s=s*n;

n–;

}

printf(“the answer is %d”,s);

getch();

}

i get ans fr factorial oly up to 10