C Programming Tutorial

Advertisements

Write program to show factorial in c



       #include<stdio.h>
       #include<conio.h>
       void main()
       {
              int a,num;
              long fact=1;

              printf("\nEnter any number : "); 
              scanf("%d",&num); 

              for(a=num;a>=1;a--)
                   fact = fact * a;
                                 
              printf("\nThe factorial is : %ld",fact); 

              getch();
       }
       
   Output : 

              Enter any number : 7 
              The factorial is : 5040




Advertisement