Wednesday, 20 June 2012

how to find the factorial of a number using c++



This the source code to find the factorial of a number
#include<iostream.h>
main()
{
      int factorial,number;
      factorial=1;
      number=1;
     cout<<"please enter the number for factorial";
     cin>>number;
    while(number>1)
{
factorial=factorial*number;
number=number-1;
}
cout<<"the factorial is<<factorial;
getch();
}
End


No comments:

Post a Comment