Program Converter;
Uses crt;
Type
bin=array[1..100] of integer;
Var
ndiv,nmod:integer;
cif,c,y:integer;
val: bin;
Begin
clrscr;
writeln('Introduzca un numero a convertir a binario:');
readln(cif);
c:=0;
Repeat
ndiv:=cif div 2;
nmod:=cif mod 2;
cif:=ndiv;
c:=c+1;
val[c]:=nmod;
until ndiv = 1;
val[c+1]:=1;
writeln;
writeln('El resultado es:');
writeln;
For y:= c+1 downto 1 do
begin
textcolor(yellow);
write(val[y]);
end;
readkey;
End.

Páginas: 1 2