5. Print all bits .

 


            

                Code :

                                 

        cin >> n;

        string st = "";

        while( n > 0 )

        {

            if ( n % 2 ==0 )

                      st = '0'+ st ;

            else

                      st = '1' + st ;

            n /= 2;

        }

        cout << st << endl ; 

 







Comments