#include<stdio.h>
#include<stdlib.h>
void main()
{
int i, a, b=1;
printf("Enter a number ") ; scanf (" %d", &a) ; for(i=a; i>0; i--) { b=b*i; } print ("factorial = %d", b) ; } |
enter a number : 5 5!=5*4*3*2*1=120
#include<stdio.h>
#include<stdlib.h>
void main()
{
int i, a, b=1;
printf("Enter a number ") ; scanf (" %d", &a) ; for(i=a; i>0; i--) { b=b*i; } print ("factorial = %d", b) ; } |
enter a number : 5 5!=5*4*3*2*1=120