Where should ‘begin’ go in pseudocode function definitions?

0
0
Asked By CuriousCoder42 On

I'm curious about how to structure pseudocode, specifically in relation to the 'begin' keyword. Should it come before or after defining a function? For example, if I have a function like this:

sum_of_numbers(num1, num2)
result = num1 + num2
return result

Should I write 'begin' before the function call or after? I'd like to understand the general style and any common practices, rather than focusing on details from specific programming languages.

5 Answers

Answered By PlayfulProgrammer16 On

For me, I prefer saying 'start' instead of 'begin' just because it flows better. But the beauty of pseudocode is that it's all about figuring out the logic first, so feel free to make it your own!

Answered By ProPseudocoder95 On

There's no strict rule for pseudocode! It's all about clarity and how well it conveys your idea to others. Use whatever format makes it understandable for you and your audience.

SyntaxSleuth33 -

Exactly! The goal is clear communication, so if your style works for you, go with it.

Answered By ClearCodeQueen On

Consistency is key! If your course recommends a specific format, it's best to stick to that. Experiment with a few styles and see what looks best to you.

Answered By SketchyScribe12 On

Honestly, I think using 'begin' and 'end' feels a bit outdated. Pseudocode is meant to be flexible, so if you can see where things start and end without those keywords, they're probably unnecessary. Indentation often suffices!

CodeCrafter76 -

Right! Clear indentation can make your pseudocode super readable without cluttering it up with extra keywords.

Answered By LogicalThinker88 On

I haven't seen 'begin' used frequently in pseudocode, but if it helps clarify things, why not? Just make sure whatever you choose is consistent throughout your code.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.