C Program to Find Factorial of Entered Number


    Using this program user can find Factorial of Entered Number. While loop checks condition first then executes the statement. While loop is also called as Entry Controlled loop. If condition is not satisfied it will not execute any statement because it cannot enter into loop.
             

Program:

//C program to find factorial of entered number by Slashmycode.com
#include<stdio.h>
#include<conio.h>
void main()
{
int i=1,f=1,num;
printf("enter a number\n");
scanf("%d",&num);
while(i<=num)
{
f=f*i;
i++;
}
printf("Factorial of %d is : %d",num,f);
//C program to find factorial of entered number by Slashmycode.com
getch();

}

Output:

No comments:

Post a Comment

Feel free to ask us any question regarding this post