Hi! I can't do a simple program in Pascal... I need to program which change any system for example dec, hex... to other system for example binary code, but (in program) i must give this system:
begginig
"Please give a system:" for example 2
"Please give second system:" for. ex. 16
"Give me a value:" 01001
"Value is..."
And now it change me from binary to 16 system a value 01001.
How it write?
Sorrry for my English but it isn't good in computers. Thanks!
[Pascal in Delphi]System to system
Started by Krad, Nov 27 2007 12:32 AM
5 replies to this topic
#1
Posted 27 November 2007 - 12:32 AM
|
|
|
#2
Posted 27 November 2007 - 09:10 AM
First question: can you do this with a pencil and paper?
When I did this program, my strategy was go from base A to decimal to base B.
When I did this program, my strategy was go from base A to decimal to base B.
#3
Posted 27 November 2007 - 10:46 AM
Uhm... no. I do it in Delphi.
Code for change a other system to binary:
But I need program in two side - from other system to other (not binary) AND change loop 'repeat' on FOR.
Code for change a other system to binary:
program NaDowolnySystem;
{$APPTYPE CONSOLE}
const
SYSTEM='0123456789ABCDEFGHIJKLMNOPRSTUWXYZ';
var
wynik:string;
NaSystem,JakaLiczba:integer;
begin
repeat
write('What system (max 34): ');
readln(NaSystem);
until NaSystem in [2..34];
write('Give value: ');
readln(JakaLiczba);
repeat
wynik:=SYSTEM[JakaLiczba mod NaSystem+1] + wynik;
JakaLiczba:=JakaLiczba div NaSystem;
until JakaLiczba=0;
writeln('Wynik: ',wynik);
readln;
end.
But I need program in two side - from other system to other (not binary) AND change loop 'repeat' on FOR.
#4
Posted 28 November 2007 - 08:26 AM
Krad, my point was that if you can't do the conversions by hand, then you will NEVER be able to program the conversions. Do you know how to do the conversions by hand?
#5
Posted 16 December 2007 - 09:24 AM
Are you using a borland compiler?
#6
Posted 27 December 2007 - 11:35 AM
If you using a borland compiler, you can use function: IntToBin, IntToHex, BinToHex etc.


Sign In
Create Account

Back to top









