Re : Please give me a hand .....
Author Message
Re : Please give me a hand .....

HI, how are you...

I am a secondary school student.  I have some problems in writing a small
Pascal program which is shown below :

Introduction : Hexadecimal is a numerical system whose base is six{*filter*} (16).
For example, the numbers highers than 9 are shown as followings :
A   =   10          B   =   11          C   =   12
D   =   13    .     E   =   14          F   =   15

Write a program to convert a decimal number to a hexadecimal number.  A
positive integer between 1 amd 32767.  A 2-byte integer is good for input
data.

The hexadecimal number of the input decimal integer. Use the format of four
characters to represent the output result and put in leading zeros if
necessary.

A sample output is shown as belows :

Enter Decimal Number  :  18
The Hexadecimal Number is   0012

Test Data  :         (a)  118       (b)  1188      (c) 11188

I should be much obliged if someone can me to solve this prolbem.

With regard.

Franco

Sun, 06 Dec 1998 03:00:00 GMT
Re : Please give me a hand .....

->HI, how are you...
->

Program word_to_hex_ala_SWAG;
var
in : word;

Function Numb2Hex(numb: Word): String;
begin
Numb2Hex := Byte2Hex(hi(numb))+Byte2Hex(lo(numb));
end;

begin
write('Enter Decimal Number : ');
writeln('The Hexadecimal Number is  ',Numb2Hex(in));
end.

{ not tested }

->
->Introduction : Hexadecimal is a numerical system whose base is six{*filter*} (16).
->For example, the numbers highers than 9 are shown as followings :
->                        A   =   10          B   =   11          C   =   12
->                        D   =   13    .     E   =   14          F   =   15
->
->Write a program to convert a decimal number to a hexadecimal number.  A
->positive integer between 1 amd 32767.  A 2-byte integer is good for input
->data.
->
->The hexadecimal number of the input decimal integer. Use the format of four
->characters to represent the output result and put in leading zeros if
->necessary.
->
->                    A sample output is shown as belows :
->
->                         Enter Decimal Number  :  18
->                         The Hexadecimal Number is   0012
->
->                    Test Data  :         (a)  118       (b)  1188      (c) 11188
->
->I should be much obliged if someone can me to solve this prolbem.

->
->With regard.
->
->Franco
->
->
->

Bjork.

Mon, 07 Dec 1998 03:00:00 GMT
Re : Please give me a hand .....

(*  OBS! one rutine was lost in my last posting! *)
(* included at the right spot below *)

->
->
->
->->HI, how are you...
->->
->
->Program word_to_hex_ala_SWAG;
->var
-> in : word;

(*  OBS! one rutine was lost  *)
(*  Include this here *)

Function Byte2Hex(numb : Byte): String;
Const
HexChars : Array[0..15] of Char = '0123456789ABCDEF';
begin
Byte2Hex[0] := #2;
Byte2Hex[1] := HexChars[numb shr  4];
Byte2Hex[2] := HexChars[numb and 15];
end;

->
->Function Numb2Hex(numb: Word): String;
->  begin
->    Numb2Hex := Byte2Hex(hi(numb))+Byte2Hex(lo(numb));
->  end;
->
->begin
->  write('Enter Decimal Number : ');
->  writeln('The Hexadecimal Number is  ',Numb2Hex(in));
->end.
->
->{ not tested }
->
->->
->->Introduction : Hexadecimal is a numerical system whose base is six{*filter*} (16).
->->For example, the numbers highers than 9 are shown as followings :
->->                        A   =   10          B   =   11          C   =   12
->->                        D   =   13    .     E   =   14          F   =   15
->->
->->Write a program to convert a decimal number to a hexadecimal number.  A
->->positive integer between 1 amd 32767.  A 2-byte integer is good for input
->->data.
->->
->->The hexadecimal number of the input decimal integer. Use the format of four
->->characters to represent the output result and put in leading zeros if
->->necessary.
->->
->->                    A sample output is shown as belows :
->->
->->                         Enter Decimal Number  :  18
->->                         The Hexadecimal Number is   0012
->->
->->                    Test Data  :         (a)  118       (b)  1188      (c) 11188
->->
->->I should be much obliged if someone can me to solve this prolbem.

->->
->->With regard.
->->
->->Franco
->->
->->
->->
->
->
->Bjork.

Mon, 07 Dec 1998 03:00:00 GMT
Re : Please give me a hand .....

Quote:

>(*  OBS! one rutine was lost in my last posting! *)
>(* included at the right spot below *)

>->
>->
>->
>->->HI, how are you...
>->->
>->
>->Program word_to_hex_ala_SWAG;
>->var
>-> in : word;
>(*  OBS! one rutine was lost  *)
>(*  Include this here *)
>Function Byte2Hex(numb : Byte): String;
>  Const
>    HexChars : Array[0..15] of Char = '0123456789ABCDEF';
>  begin
>    Byte2Hex[0] := #2;
>    Byte2Hex[1] := HexChars[numb shr  4];
>    Byte2Hex[2] := HexChars[numb and 15];
>  end;
>->
>->Function Numb2Hex(numb: Word): String;
>->  begin
>->    Numb2Hex := Byte2Hex(hi(numb))+Byte2Hex(lo(numb));
>->  end;
>->
>->begin
>->  write('Enter Decimal Number : ');
>->  writeln('The Hexadecimal Number is  ',Numb2Hex(in));
>->end.
>->
>->{ not tested }
>->
>->->
>->->Introduction : Hexadecimal is a numerical system whose base is six{*filter*} (16).
>->->For example, the numbers highers than 9 are shown as followings :
>->->                        A   =   10          B   =   11          C   =   12
>->->                        D   =   13    .     E   =   14          F   =   15
>->->
>->->Write a program to convert a decimal number to a hexadecimal number.  A
>->->positive integer between 1 amd 32767.  A 2-byte integer is good for input
>->->data.
>->->
>->->The hexadecimal number of the input decimal integer. Use the format of four
>->->characters to represent the output result and put in leading zeros if
>->->necessary.
>->->
>->->                    A sample output is shown as belows :
>->->
>->->                         Enter Decimal Number  :  18
>->->                         The Hexadecimal Number is   0012
>->->
>->->                    Test Data  :         (a)  118       (b)  1188      (c) 11188
>->->
>->->I should be much obliged if someone can me to solve this prolbem.

>->->
>->->With regard.
>->->
>->->Franco
>->->
>->->
>->->
>->
>->
>->Bjork.

I'd hate to be in this guy's shoes when his teacher asks him to
explain how it works! - (He might be safe if his teacher thinks that
the Clinton's are honest, however!)

Mon, 07 Dec 1998 03:00:00 GMT

 Page 1 of 1 [ 4 post ]

Relevant Pages