program binary

program binary

Hi

I want to write a program in pascal that ask a user to input a decimal number and then return its binary equivalent in the minimum number of bits required to repesent the number. In pascal language please

Thks

View Answers

June 24, 2011 at 10:39 AM

Try this:

program decimalToBinary;

const v:array[0..7] of byte=(1,2,4,8,16,32,64,128); {powers of 2}
      bin:array[false..true] of char='01';
      oct:array[0..7] of char='01234567';

{Decimal to binary}
function dec2bin(b:byte):string;
 var s:string;
     i:byte;
 begin
  s:='';
  for i:=7 downto 0 do
   s:=s+bin[(v[i] and b=v[i])];
  dec2bin:=s;
 end;

June 29, 2011 at 10:47 PM

Many Thanks

Will try it

Rgds









Related Tutorials/Questions & Answers:
program binary
program binary  Hi I want to write a program in pascal that ask a user to input a decimal number and then return its binary equivalent in the minimum number of bits required to repesent the number. In pascal language please
binary search program
binary search program  write a program to searching a string using binary search
Advertisements
binary search program
binary search program  write a program to searching a string using binary search
binary search program
binary search program  write a program to searching a string using binary search
binary search program
binary search program  write a program to searching a string using binary search
binary search program
binary search program  write a program to searching a string using binary search
swing program for decimal to binary
swing program for decimal to binary  swing program for decimal to binary
Write a program in Java to convert Decimal number into Binary number
Write a program in Java to convert Decimal number into Binary number  Hi, I have decimal number and I want to convert it to Binary. How to Write a program in Java to convert Decimal number into Binary number? Thanks
binary
binary  Hi I want to write a program in pascal that ask a user to input a decimal number and then return its binary equivalent in the minimum number of bits required to repesent the number. Thks
Convert Text to Binary
to Binary. The following program provides you the functionality to convert Text to Binary. Code Description:ADS_TO_REPLACE_1 In the program code below, to take... Convert Text to Binary      
Convert Text to Binary
Convert Text to Binary       In this section, we will learn how to convert Text to Binary. The following program provides you the functionality to convert Text to Binary
Binary tree
Binary tree  a. Construct a method to implement a binary tree using an array. b. Implement the binary tree to store numbers in sorted order
ModuleNotFoundError: No module named 'binary'
ModuleNotFoundError: No module named 'binary'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'binary' How to remove the ModuleNotFoundError: No module named 'binary'
Binary tree
Binary tree  hii, What is binary tree?   hello,ADS_TO_REPLACE_1 A binary tree is a tree in which every node has exactly two links i.e left and right link
binary tree
binary tree  can a binary tree be implemented with out comparing...://www.roseindia.net/java/java-get-example/java-binary-tree-code.shtml http://www.roseindia.net/java/java-get-example/java-binary-tree-insert.shtml
binary tree
binary tree  how to count no. of nodes in a binary tree for mlm if it complet tree or incomplet tree in php using mysql db
octal to binary
octal to binary  i want to know how to convert a octal to binary number   Here is a java example that converts octal to binary. import... binary=Integer.toBinaryString(i); System.out.println(binary
BINARY TO DECIMAL - Java Beginners
BINARY TO DECIMAL  HELP ME PLSS. PROGRAM THAT CONVERTS BINARY TO DECIMAL  Hi friend, Program to convert Binary To Decimal : import... (System.in); System.out.print ("Enter a binary number "); String str
Binary Search - Java Beginners
Binary Search  how to use Binary think in java give me the Binary Search programm thx
ModuleNotFoundError: No module named 'chromedriver-binary'
ModuleNotFoundError: No module named 'chromedriver-binary'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'chromedriver-binary' How to remove the ModuleNotFoundError
ModuleNotFoundError: No module named 'phantomjs-binary'
ModuleNotFoundError: No module named 'phantomjs-binary'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'phantomjs-binary' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'prison-no-binary'
ModuleNotFoundError: No module named 'prison-no-binary'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'prison-no-binary' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'pycopy-binary'
ModuleNotFoundError: No module named 'pycopy-binary'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'pycopy-binary' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'talib-binary'
ModuleNotFoundError: No module named 'talib-binary'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'talib-binary' How to remove the ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'yxspkg_binary'
ModuleNotFoundError: No module named 'yxspkg_binary'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'yxspkg_binary' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'attrs-binary'
ModuleNotFoundError: No module named 'attrs-binary'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'attrs-binary' How to remove the ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'binary-core'
ModuleNotFoundError: No module named 'binary-core'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'binary-core' How to remove the ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'binary-helpers'
ModuleNotFoundError: No module named 'binary-helpers'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'binary-helpers' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'binary-pairs'
ModuleNotFoundError: No module named 'binary-pairs'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'binary-pairs' How to remove the ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'binary-repr'
ModuleNotFoundError: No module named 'binary-repr'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'binary-repr' How to remove the ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'binary-tostring'
ModuleNotFoundError: No module named 'binary-tostring'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'binary-tostring' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'chromedriver-binary'
ModuleNotFoundError: No module named 'chromedriver-binary'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'chromedriver-binary' How to remove the ModuleNotFoundError
ModuleNotFoundError: No module named 'dataclasses-binary'
ModuleNotFoundError: No module named 'dataclasses-binary'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'dataclasses-binary' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'fortran-binary'
ModuleNotFoundError: No module named 'fortran-binary'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'fortran-binary' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'pkgme-binary'
ModuleNotFoundError: No module named 'pkgme-binary'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'pkgme-binary' How to remove the ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'PyICU-binary'
ModuleNotFoundError: No module named 'PyICU-binary'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'PyICU-binary' How to remove the ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'terraform-binary'
ModuleNotFoundError: No module named 'terraform-binary'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'terraform-binary' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'binary_clock'
ModuleNotFoundError: No module named 'binary_clock'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'binary_clock' How to remove the ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'binary-heap'
ModuleNotFoundError: No module named 'binary-heap'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'binary-heap' How to remove the ModuleNotFoundError: No module named '
ModuleNotFoundError: No module named 'binary-refinery'
ModuleNotFoundError: No module named 'binary-refinery'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'binary-refinery' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'binary-search'
ModuleNotFoundError: No module named 'binary-search'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'binary-search' How to remove the ModuleNotFoundError: No module named
ModuleNotFoundError: No module named 'binary-to-string'
ModuleNotFoundError: No module named 'binary-to-string'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'binary-to-string' How to remove the ModuleNotFoundError: No module
ModuleNotFoundError: No module named 'binary-tree'
ModuleNotFoundError: No module named 'binary-tree'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'binary-tree' How to remove the ModuleNotFoundError: No module named '
universal binary for ipad iphone
universal binary for ipad iphone  How can i create a universal binary for iPad and iPhone
Binary to decimal - Java Beginners
Binary to decimal  Need help pls.. i cannot run this program... pls correct my program... i really appreciate your answers... thank you very mucha... = Integer.parseInt(JOptionPane.showInputDialog("Input Binary:")); String c = args[0
JAVA: Recusrion, Binary Search
JAVA: Recusrion, Binary Search  I want to learn about Binary Search..., Inheritance, Interface, etc for this program. I also know that this needs to be implemented into a lot of classes. So if you could figure out this program for me
ModuleNotFoundError: No module named 'django-binary-database-files'
ModuleNotFoundError: No module named 'django-binary-database-files'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'django-binary-database-files' How to remove
ModuleNotFoundError: No module named 'minimal-binary-coding'
ModuleNotFoundError: No module named 'minimal-binary-coding'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'minimal-binary-coding' How to remove the ModuleNotFoundError
ModuleNotFoundError: No module named 'minimal-binary-coding'
ModuleNotFoundError: No module named 'minimal-binary-coding'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'minimal-binary-coding' How to remove the ModuleNotFoundError
ModuleNotFoundError: No module named 'oclgrind-binary-distribution'
ModuleNotFoundError: No module named 'oclgrind-binary-distribution'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'oclgrind-binary-distribution' How to remove

Ads