familia

familia

jueves, 30 de junio de 2011

programado en visual fox "convierte cualquier numero a binario,octal,hexadecimal"

CLEAR
?"PROGRAMA QUE CONVIERTE UN NUMERO CUALQUIERA A: BINARIO,OCTAL,DECIMAL"
input"ingrese un numero entero" to x
?"el numero se convertira a: binario"
i=0
n=0
DO while x>0
r=MOD(x,2)
x=INT(x/2)
n=n+r*(10^i)
i=i+1
ENDDO
?"numero ya convertido a binario: "+alltrim(str(INT(n)))

input"ingrese un numero entero" to x
?"el numero se convertira a: octal"
i=0
n=0
DO while x>0
r=MOD(x,8)
x=INT(x/8)
n=n+r*(10^i)
i=i+1
ENDDO
?"numero convertido a octal: "+alltrim(str(INT(n)))

input"ingrese un numero entero" to x
?"el numero se convertira a: hexadecimal"
i=0
n=0
DO while x>0
r=MOD(x,16)
x=INT(x/16)
n=n+r*(10^i)
i=i+1
ENDDO
?"numero convertido a hexadecimal: "+alltrim(str(INT(n)))

No hay comentarios:

Publicar un comentario