C++ Programming Blog

 
 
 

Image

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

 void binary_code(int);

 void main( )
    {
       clrscr( );
       textmode(BW80);

       int n;
       int bits;

       cout<<\"\\n Enter the value of n = \";
       cin>>n;

       cout<<\"\\n The Binary code of value of n = \";
       binary_code(n);

       cout<<\"\\n\\n Enter the number of bits to shift right = \";
       cin>>bits;

       n=n>>bits;

       cout<<\"\\n The value of n after Right Shifting = \"<<n;
       cout<<\"\\n\\n The Binary code of modified value of n = \";
       binary_code(n);

       getch( );
    }


 //---------------------------  binary_code( )  --------------------------//


 void binary_code(int number)
    {
       int remainder;
       int qutiont;

       int count=0;
       int x=(wherex( )+16);
       int y=wherey( );

       if(number>0)
      {
         while(number>0)
        {
           qutiont=number/2;
           remainder=number%2;
           number=qutiont;

           gotoxy((x-count),y);
           cout<<remainder;

           count++;
        }
      }

       else
      {
         gotoxy((x-count),y);
         cout<<\"0\";
      }
    }

    Related Post:
  1. Program for displaying data in tabular format

  2. Program of Boundary Fill (8 Connected Point).

  3. Program that reads a numbers , computes and displays the factorial of the given number using recursion

  4. Program of Midpoint Circle Drawing

  5. Program that reads two integers and an operator , evaluates and displays the result using switch-case statement

  6. Program that take font and background color and text input from a user and display it in right aligned

  7. Implement a Matrix class representing 2-dimensional matrix with the following functionalities i.e. operators + , - , * , == , += &lt;&lt; , &gt;&gt; etc

  8. Program to fill a Circle using Scan-Line Circle Fill Algorithm

  9. Program to illustrate self-referential structures Linked List

  10. Program to fill a Polygon using Scan Line Polygon Fill Algorithm

  11. Program to draw a Bezier Curve of nth degree

  12. Program to perform linear sort

  13. Program that implements overloaded - minus unary operator.

  14. Program that provides an example of scope resolution operator

  15. Program that reads a number and displays it with its digits in reverse order using do-while loop

  16. Program to illustrate the different features of an array of char known as string

  17. Program to search an element in an array using Binary search

  18. Program to swap two variables using header file swap.h

  19. Program to read a Linear System of Equations,then evaluate it by using Gauss-Elimination Method and show the result

  20. Program that reads marks obtained by a student in a test of 100 marks and computes his grade

 
 
Didn't find what you were looking for? Find more on Program to show the use of Bitwise Operator Right Shift ( &gt;&gt; )