Turbo pascal help please

Hi BlackVault

It's been a bloody long time since I done some Pascal programming. :eek: But I will try my best. Someone might provide you with a better solution. First I think you will have to convert it to a String unless it already is.

Code:
program StringTest; 
var
   s: String;
   YourNumber: Integer;

function RightStr(
  const S: String;
   Count: Integer
 ):String;
 
begin
   YourNumber := 12304;
   Str(YourNumber,s);
   Writeln (RightStr(s,2));
end.

The syntax might be slightly wrong it has been years but you get the idea.
 
If the 5 digit number is in a numeric data type variable then it should just be a case of doing a MOD by 100.

How will that find the last two numbers? I'm only getting it to return one number based on what you mentioned. It's discarding the 0 in 04 for example

Blackvault
 
Last edited:
If you want to display 04 then you'll need to convert it to a string at some point anyway so just check if it's less than ten and prefix a zero if it is.
 
Back
Top Bottom