Showing posts with label to find the factorial of a number. Show all posts
Showing posts with label to find the factorial of a number. Show all posts

Saturday, 23 June 2012

how to find the factorial of a number using while loop in c++


how to find a factorial of a number in c++
How to find a factorial of a number in c++:- Here is the source code to find the factorial of a number using while loop in c++.It is quite simple including the body.So try it and give your feed back to me.
#include<iostream.h>
#include<conio.h>
main()
{
      int x;
      cout<<"enter the value for which you want the factorial:";
      cin>>x;
      int f=1;
      int n=1;
      while(n<=x)
      {
                 f=f*n;
                 n=n+1;
                 }
                 cout<<"this is the required value:"<<f<<endl;
                 getch();
                 }
End