Friday, 18 January 2013

factor in c++ using oop

 /*Factorial Using loops */
                #include <iostream>
                #include <conio>
class fact
{
private:
int a,i;
public:
           fact()
        {  i=1;}


        void input()
        {
          cout<<"Enter any no \n";
          cin>>a;

          cout<<" factorial is\n";
          for(int j=a;j>0;j--)
            {
              cout<<j<<"";
            }

            while(a>0)
          {
            i=i*a;
            a--;
          } cout<<"="<<i;
       }



       };


                 void main()
                {
                  fact m;
                  m.input();
                  getch();
                  }

0 comments:

Post a Comment