4
Contributors
3
Replies
5
Views
5 Years
Discussion Span
Last Post by Bilal gulbaz
Featured Replies
  • 4

    try this following code : [CODE]Program Decimal_Binary; Uses WinCrt; Var Dec,Deci: Integer; Bin: String; Ul:Char; Begin Repeat Clrscr; Writeln('Decimal to Binary Convertion Program'); Writeln('======================================'); Writeln; Write('Input Decimal Number: ');Readln(Dec); Deci:=Dec; Bin:=''; Repeat If(Dec Mod 2 = 0) Then Bin:='0'+Bin Else Bin:='1'+Bin; Dec:=Dec Div 2; Until Des=0; Writeln; Writeln(Deci,' Decimal = … Read More

  • [CODE=DELPHI] function IntToBin( Value: integer; Digits: integer ): string; begin result := StringOfChar ( '0', digits ) ; while value > 0 do begin if (value and 1) = 1 then result[digits] := '1'; dec (digits) ; value := value shr 1; end; end; [/CODE] Read More

4

try this following code :

Program Decimal_Binary;
Uses WinCrt;
Var
	Dec,Deci: Integer;
	Bin: String;
	Ul:Char;
Begin
	Repeat
		Clrscr;
		Writeln('Decimal to Binary Convertion Program');
		Writeln('======================================');
		Writeln;
		Write('Input Decimal Number: ');Readln(Dec);
		Deci:=Dec;
		Bin:='';
		Repeat
			If(Dec Mod 2 = 0) Then
				Bin:='0'+Bin
			Else
				Bin:='1'+Bin;
			Dec:=Dec Div 2;
		Until Des=0;
		Writeln;
		Writeln(Deci,' Decimal = ',Bin,' Binary');
		Writeln;
		Write('Try Again? [Y/N]: ');Readln(Ul);
		Ul:=Upcase(Ul);
	Until (Ul<>'Y');
End.

hope it helps

Comments
helping..
Thx..relly helps :)
good one
2
function IntToBin( Value: integer; Digits: integer ): string;
begin
  result := StringOfChar ( '0', digits ) ;
    while value > 0 do begin
      if (value and 1) = 1 then
        result[digits] := '1';
      dec (digits) ;
      value := value shr 1;
    end;
end;
Comments
Thx.. :)
This question has already been answered. Start a new discussion instead.
Please be thoughtful and detailed and be sure to adhere to our posting rules.