Write a program for factorial of a number.

Write a program for factorial of a number.

 

 

#include<stdio.h>

#include<conio.h>

void main()

{

clrscr();

int  fact=1,i,n;

printf(“Enter a number:”);

scanf(“%d”,&n);

for(i=1;i<=n;i++)

{

 fact=fact*i;

}

printf(“Factorial of %d is:”,fact);

getch();

}

 

 

Output:

 

Enter a number:4

Factorial of 4 is :24

 


Comments