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
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!
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.
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.
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!
Right! Clear indentation can make your pseudocode super readable without cluttering it up with extra keywords.
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.
Exactly! The goal is clear communication, so if your style works for you, go with it.