NBA - Boston Celtics

Saturday, 20 October 2012

FACTORIAL USING FUNCTION


#include<iostream.h>
int fac(int a);
int fact=1,a;
void main()
{
int result;
result=fac(fact);
cout<<result;
}
int fac(int a)
{
int n;
cout<<"enter the value of n to fnd its factorial : ";
cin>>n;
for(int i=1;i<=n;i++)
fact=fact*i;
}


No comments:

Post a Comment