• Congratulations to the Class of 2024 on your results!
    Let us know how you went here
    Got a question about your uni preferences? Ask us here

Global Variables in Pseudocode + Time Formatting (1 Viewer)

Kn1ght_M4r3

Member
Joined
Mar 3, 2003
Messages
332
Location
D o w n l o a d C o m p l e t e .....
hey how do i declare the global variables in pseudocode so that they can be used in both sub programs and the mainprogram =/ i dont remember this. =0,

wat im trying to do is use an errorcounter that will be used in subprogram and then use it to display the number of errors in the mainprogram.
eg:
Display "number of errors encountered:" ErrorCounter


Another question
Two race times are to be entered in the form of hours, minutes, seconds, and hundredths of a second, and if the times entered are valid (valid times are between 8am and 11pm, minutes and seconds are between 0 and 59, hundredths are between 0 and 99

Is it possible to write the code
Format Time As (HH:MM:SS:HS)
N.B that Hs is hundreths of a second, ss is seconds an mm is minutes and HH is hours heehhe. =)
Coz wat i wanna do is then validate it, by maybe using casewhere statements.

thanx guys i owe yah one. :p :eek: :eek:
 

grendel

day dreamer
Joined
Sep 10, 2002
Messages
103
Gender
Male
HSC
N/A
in Pascal you can do it like this.

You pass the variable in as a parameter.

If you don't want the variable to be modified by the subprogram you write the following:

Procedure SubProg(ErrorCounter:integer);
Begin
..........
End;


where SubProg is just the name ofthe subprogram and errorCounter is the variable you want to pass.

If you do want the variable to be modified by the subprogram you write the following:

Procedure SubProg(var ErrorCounter:integer);
Begin
..........
End;

the code for the module follows that line.

since Pascal bears an uncanny resemblance to pseudocode i think you can do this. you can maybe change "Procedure" to "subprogram".

You can also comment your pseudocode to avoid any confusion.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Top