img
Question:
Published on: 21 November, 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