Program to find factorial of number using non-recursive function


#include <iostream.h>
#include <conio.h>

int factorial (int i);                     //Declaration (Prototype)
void main( )
{
    int a, fact;
    cout<<"\n Enter any Number : " ;
    cin>>a;
    fact = factorial( a ) ;
    cout<<"\n Factorial value : " << fact ;
    getch( );
}
int factorial ( int x)
{
    int f =1, i ;
    for (i = x; i >= 1; i--)
       f = f * i ;
    return (f );
}

1 comment:

  1. Thank you for the good writeup. It in fact was a
    amusement account it. Look advanced to more added agreeable from you!
    By the way, how can we communicate?

    Here is my homepage ... cellulite treatment reviews

    ReplyDelete