F How to find factorial of any given number? [using C] | CodeTheta

How to find factorial of any given number? [using C]


Here is a simple a factorial calculation program which is written is C . Code is written in very easy process.
here you can see the simple program of factorial. This program calculate the given value using function , here you can see i use factorial function, and after that i pass the integer value in to this. In starting portion of the program we use two integer to calculate the value.

n= number entered by the user.
f= factorial value of the number which is entered by the user.

In the last portion of the program you can see, that's the main logic of the factorial programming. Main pseudo code is:
n*factorial(n-1)
 
/* http://native-code.blogspot.in */

#include<stdio.h>
#include<conio.h>
void main()
{
int n,f;
int factorial(int);
printf("/* http://native-code.blogspot.in */");
printf(""\n Enter The Number: ");
scanf("%d",&n);
f=factorial(n);
printf("\n Factorial is: %d",f);
getch();
}
int factorial(int n)
{
if(n==1)
return(1);
else
return(n*factorial(n-1));
}

/* http://native-code.blogspot.in */

For better understanding you have to run this code in you PC.

1 comments:

This blog awesome and i learn a lot about programming from here.The best thing about this blog is that you doing from beginning to experts level.

Love from

Reply

Post a Comment