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)
#include<stdio.h>
#include<conio.h>
void main()
{
int n,f;
int factorial(int);
printf("/* http://codetheta.com */");
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));
}
For better understanding you have to run this code in you PC.
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)
#include<stdio.h>
#include<conio.h>
void main()
{
int n,f;
int factorial(int);
printf("/* http://codetheta.com */");
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));
}
For better understanding you have to run this code in you PC.
Post a Comment