C Program to Find Factorial of n using While loop

Write C Program to Find Factorial of n using While loop

//WAP to find the factorial of n using

#include <stdio.h>

int main()
{

	int n, i, fact = 1;

	printf("Enter the number :--> ");
	scanf("%d", &n);

	i = 1;

	while(i <= n)
	{
        fact = fact * i;
        i++;
	}

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

	return 0;
}

Output:

Enter the number :--> 6
The factorial of 6 is 720

≪ Previous | Next ≫