Wednesday 14 December 2016

Write a Program that inputs a decimal number and convert it to binary digits.



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

         void binary(unsigned long int decimal)
         {
               int remainder; 
               if (decimal <= 1)
               {
                  cout<< decimal;
                  return
               }
               remainder = decimal % 2
               binary(decimal >> 1);
               cout<<  reminder; 
         }
         
          int main()
         {
               unsigned long int num; 
               clrscr(); 
               cout<< "Enter decimal"
               cin>> num; 
               cout<< endl<< "Binary of  "<< num<< "is " ;
               binary(num);
                return 0;
         }

Output:


No comments:

Post a Comment

If you have any doubt please let me know

Methods in JAVA Language

 In general, a way may be thanks to perform some task. Similarly, the tactic in Java may be a collection of instructions that performs a sel...