img
Question:
Published on: 3 December, 2024

Write a C program to find the factorial of any number.

Answer:

 

#include<stdio.h>
#include<conio.h>
main()
{
	int n;
	long int fact=1;
	printf("\n Enter any number");
	scanf("%d",&n);
	if(n==0)
	 printf("\n The result=%d",fact);
	else
	{
		do
		{
			fact=fact*n;
			n--;
		}while(n>0);
		printf("\n The result=%d",fact);
	} 
	getch();
}


Output:

Random questions