C program to calculate factorial using for loop

 C program to calculate factorial using for loop



/***********************************************************

 C program to calculate factorial using for loop

 ***********************************************************/

 

 #include<stdio.h>

 #include<conio.h>

 void main()

 {

     int i,num,fact=1;

     clrscr();

     printf("** OUTPUT**\n");

     printf("Enter number to calculate factorial\n");

     scanf("%d",&num);

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

     {

        fact=fact*i;

     }

     printf("The factorial of %d is %d\n",num,fact);

     

     printf("End of program");

 }


** OUTPUT**

Enter number to calculate factorial

5

The factorial of 5 is 120

End of program


टिप्पणी पोस्ट करा

0 टिप्पण्या