Comments

Wednesday, October 17, 2012

Find Factorial of the number using function

Posted by at 8:37 AM Read our previous post


Object
1-  Find Factorial of the number using function


Source code
#include <iostream>
using namespace std;

int factorial(int);

int factorial(int num)
{      int fact=1;
       for(num;num>0;num--)
       {
              fact=fact*num;
       }
       return (fact);

}

void main(void)
{int num,fact,ans;
cout<<"Enter a number for fortorial"<<endl;
cin>>num;

ans=factorial(num);
cout<<"Answer is = "<<ans<<endl;


}




Output

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Popular Posts

Labels

© Codepirate is powered by Blogger - Template designed by Stramaxon - Best SEO Template