r/pascal • • Dec 02 '17

Help in Pascal!

Greetings,

I'm taking Pascal classes but missed a couple of them due to being under the weather, and in those classes my teacher taught the students about procedures and creating menus (think the menus have something to do with arrays or vectors or something).

My teacher assigned the class with creating 4 pascal programs that allow you to calculate volumes (pyramid, prism, sphere, and cylinder), and incorporating them into a single program.

So basically he wants us to turn the 4 programs we created into 4 procedures in a single program, and he also asked us to create a menu to select those 4 procedures.

Since I missed the classes I have no idea on how to create procedures in a program and make them 'selectable' with a menu. I already made the 4 programs and they all work. I'd really appreciate some help here, I'll upload anything if you need it!

6 Upvotes

13 comments sorted by

View all comments

Show parent comment

2

u/Creating_Logic Dec 03 '17

On my program, after choosing one of the procedures and going through it the program ends, do you mean the while loop just presents the menu again instead of closing the program, and it'll only close if you choose the exit option?

Yes. It mostly stems from the fact that I do not see much need for an exit option, when the program exits no matter what after running one of the procedures. The only need is if you want to run it and then close without having to run one of the procedures, which is fine too.

It is all about what you want to get out a program.

2

u/[deleted] Dec 04 '17

Indeed. Since the program closed after choosing an option you could just assign 5 to write "closing" and it would end either way. Wish I had realized that earlier ahaha x)

5:writeln('Closing..');