Factorial program in C,find given number factorial,find the factorial of the given number,factorial C program,given number factorial,using C find the factorial of given number,Write a program to find the factorial of the given number using in C program language,using C find factorial,C factorial,find the factorial in C language
Factorial of given number
The below program is for Factorial of the given number
#include<stdio.h>
main()
{
int n,fact = 1;
printf("Enter number\n");
scanf("%d",&n)
;
while(n>1)
{
fact = fact*n;
n--;
}
printf("Factorial of given number is %d\n",fact);
}
Output:
Enter number
6
Factorial of given number is 720
Factorial of given number
The below program is for Factorial of the given number
#include<stdio.h>
main()
{
int n,fact = 1;
printf("Enter number\n");
scanf("%d",&n)
;
while(n>1)
{
fact = fact*n;
n--;
}
printf("Factorial of given number is %d\n",fact);
}
Output:
Enter number
6
Factorial of given number is 720
#include
ReplyDeleteint fact(int n)
{
if(n==1)
return 1;
else
return n*fact(n-1);
}
int main()
{
int n;
printf("Enter the factorial number\n");
scanf("%d",&n);
printf("Factorial of %d is %d\n",n,fact(n));
}
c language example programs for code writers
ReplyDeleteDo while loop c example with continue