
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

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;

Many Thanks
Will try it
Rgds
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.