Generate
a program which gives the factorial of a number using a function fat().
The Factorial mean extended to non-integer arguments, while
retaining its most important properties; this involves more advanced mathematics,
notably techniques from mathematical analysis.
In this program we are calculating the factorial by using
function. In the top first we initialize factorial {int fact (int f)} in the
top before void main (), and the process will define after the void main(). In
advantage is here, if anywhere want to use factorial we only use int fact (int
f), not to repeat the process.
Source Code:
# include <iostream>
# include <iostream>
using namespace std;
int fact(int f);
void main ()
{
int
a, f=1;
cout<<"Enter
the number of factorial\t";
cin>>a;
for
(int i=a; i>0; i--)
f=f*i;
cout<<f<<endl;
}
int fact (int f)
{
return
f;
}
Output:
Tag: factorial in c, programming in c, c, learning c, c compiler,
c programming language, java programming, visual basic, programming with c, c
software download, turbo c download, in c programming, computer programming, programming
with c, c programming program, download turbo c, c software download
| Follow @computercolumns | ||||

0 comments:
Post a Comment
Some HTML Code