• 0

Pseudo code


Question

Hello, this is for my AS Computing exam

 

My teacher is fairly clueless so I was just wondering if this is correct?

 

It's about Nested Statements

 

Write your own nested statement in pseudo code to print ?Accepted? if someone is a member and

over 18, ?Not a member? if they are not a member or ?Underage? if they are not 18.

 

if person EQUALS Member

if person EQUALS >= 18

PRINT "Accepted"

ELSE

PRINT "Underage"

End if

ELSE

PRINT "not a member"

End if

 

Im mostly concerned about if this is in the right format, should the ELSE PRINT "not a member" come last? and is >= appropriate for pseudo code?

 

Thanks in advance

Link to comment
https://www.neowin.net/forum/topic/1203017-pseudo-code/
Share on other sites

4 answers to this question

Recommended Posts

  • 0

That looks correct, with the exception that "EQUALS >=" is nonsense, either write "greater than or equal" or ">=", but not both.

 

Pseudo-code has no formal rules, just keep it consistent. For instance some of your keyword are all-caps and some aren't, that's not good. Pick a style and stick with it.

Link to comment
https://www.neowin.net/forum/topic/1203017-pseudo-code/#findComment-596288845
Share on other sites

  • 0
  On 01/03/2014 at 16:38, Andre S. said:

That looks correct, with the exception that "EQUALS >=" is nonsense, either write "greater than or equal" or ">=", but not both.

 

Pseudo-code has no formal rules, just keep it consistent. For instance some of your keyword are all-caps and some aren't, that's not good. Pick a style and stick with it.

 

Ahh I see,

 

So it could be

 

IF person = Member

IF person >=18

PRINT "Accepted"

etc

 

Thank you!

Link to comment
https://www.neowin.net/forum/topic/1203017-pseudo-code/#findComment-596288857
Share on other sites

  • 0

For your exam... So are your posting this question during it??? huh.png

 

Your answer looks pretty good to me, the only thing I would change (apart from consistency of capitals) is the use of the word "EQUALS". A person is a person, a person does not equate directly to a membership status or a number. This would be better:

If person is a Member

    If age of person is greater than or equal to 18

        PRINT "Accepted"

    Else

        PRINT "Underage"

    End if

Else

    PRINT "Not a member"

End if

Rules on pseudo code are pretty lax, as long as the logic is sound and it makes sense, it really doesn't matter too much. With specific regard to use of '>=' and similar expressions, think about who will be reading the pseudo code you've written (I'm talking in general here, not specifically about the exam). If you're writing it just for yourself or for others who understand programming, it's obviously going to be fine; whereas if someone unfamiliar with programming were to need to look at it, who may perhaps be unfamiliar with the expression you are intending on using, it may be best to revert to words to avoid confusion.

 

The order of conditional checks in your logic is perfectly sound. If you were to attempt to follow the precise order of logical requirements in the question, you may end up with this:

If person is a Member

    If age of person is greater than or equal to 18

        PRINT "Accepted"

    End if

Else, if person is not a member

    PRINT "Not a member"

Else, if age of person less than 18

    PRINT "Underage"

End if

Which would be incorrect because the logic does not actually work!


  On 01/03/2014 at 16:46, Kerberonix said:

Ahh I see,

 

So it could be

 

IF person = Member

IF person >=18

PRINT "Accepted"

etc

 

Thank you!

 

No, see above!

Link to comment
https://www.neowin.net/forum/topic/1203017-pseudo-code/#findComment-596288859
Share on other sites

  • 0
  On 01/03/2014 at 16:49, theblazingangel said:

For your exam... So are your posting this question during it??? huh.png

 

Your answer looks pretty good to me, the only thing I would change (apart from consistency of capitals) is the use of the word "EQUALS". A person is a person, a person does not equate directly to a membership status or a number. This would be better:

If person is a Member

    If age of person is greater than or equal to 18

        PRINT "Accepted"

    Else

        PRINT "Underage"

    End if

Else

    PRINT "Not a member"

End if

Rules on pseudo code are pretty lax, as long as the logic is sound and it makes sense, it really doesn't matter too much. With specific regard to use of '>=' and similar expressions, think about who will be reading the pseudo code you've written (I'm talking in general here, not specifically about the exam). If you're writing it just for yourself or for others who understand programming, it's obviously going to be fine; whereas if someone unfamiliar with programming were to need to look at it, who may perhaps be unfamiliar with the expression you are intending on using, it may be best to revert to words to avoid confusion.

 

The order of conditional checks in your logic is perfectly sound. If you were to attempt to follow the precise order of logical requirements in the question, you may end up with this:

If person is a Member

    If age of person is greater than or equal to 18

        PRINT "Accepted"

    End if

Else, if person is not a member

    PRINT "Not a member"

Else, if age of person less than 18

    PRINT "Underage"

End if

Which would be incorrect because the logic does not actually work!

 

No, see above!

I looked at a few similar questions against the mark scheme and some of them allow the use of expressions, but some of them don't even list them... but they all include the use of words such as the ones you used. So the safe option is to write it to a standard (like you did with actually writing "greater than" etc) which everyone may be able to read, which is what I shall do from now on.

 

And my exam isn't until the end of june :p

 

Thank you!

Link to comment
https://www.neowin.net/forum/topic/1203017-pseudo-code/#findComment-596288919
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • I love space RPGs, and this one will no doubt scratch that itch. Im still modding the crap out of Starfiled. Can't wait.
    • Nah, the problem is still Windows. If you install Linux on a gaming PC, you will get better performance in games.
    • You could just do it now yourself with all the tools out there or the right Powershell scripts. Nothing stops you from tinkering away at it like the Tiny11 dev(s) do. It's easier to remove and turn off stuff when you're targeting a specific device like a gaming handheld. All the work/office bits alone are probably 60-70% of the code anyway.
    • hah, not for long. Microsoft will add copilot, video recording, social media integration, Microsoft 365 outlook, cdrom support, printer drivers, xbox memory card manager for zune music players, dedicated film and tv app for several providers that don't actually support it, and windows media centre for backward compatibility for anyone still using a sling tv box.... then they'll decide that it also need the start menu so they can provide a nice place to show your recent blank space that takes up half the screen while showing you full screen ads asking you to setup your Microsoft account for xbox. Then the only good thing it actually did, they'll let the new intern show their coding skills and the ABXY buttons will be changed around to 1256 because its better for international support or something, but ... at the end of it all, this time next year because Microsoft loves supporting software and hardware, the Asus oem won't get any more updates for it's Ally and it'll be forgotten faster than the Xbox Samsung TVs
    • Grounded 2 out next month, bringing fans a new miniaturized survival adventure by Pulasthi Ariyasinghe Alongside Avowed and The Outer Worlds 2, Obsidian Entertainment will officially be releasing three games in 2025. The first-party Xbox studio surprise revealed Grounded 2 during the Xbox Games Showcase event today. The same four kids from the original survival game are returning for this new adventure, and this time, they are miniaturized in a park. Check out the trailer above. Grounded 2 is set two years after the events of the first game, and this time, it's Brookhollow Park that will become the playground for players. Obsidian is getting help from Eidos Montréal as well, saying that the collaboration is adding more depth, danger, and discovery to the experience. In addition to building on the first game's features, Grounded 2 is introducing Buggies as one of its biggest features. Essentially bug mounts, these will let you ride ally bugs and use them across various operations in the game, including combat and building. Mounts had been one of the biggest requests by fans in the first game, and Obsidian says it has delivered with plenty of deep integrations Just like the original, Grounded 2 will be an early access title at launch, aiming to build out the game, story, and features with the community. Here are the key features of the Early Access/Game Preview launch: Omni-Tool introduced: A major quality of life upgrade that combines the hammer, axe, shovel, and wrench into one all-purpose tool, saving precious backpack space and streamlining your survival experience.  Story: In Grounded 2, we won’t tell you the whole story at the launch of Game Preview, but there’ll be enough there for you to start uncovering mysteries, chasing clues, and sharing your wildest theories right away (yes, we’re watching).  Expanded world-building brands: Expect the return of in-world favorites like Punch-O and Minotaurs & Myrmidons, alongside new brands and scenery that don’t just look cool—they tell a story (if you know where to look)—all coming together to bring Brookhollow Park to life with that signature Grounded charm.  New and returning bugs: Face off against familiar foes and never-before-seen creepy crawlies like the graceful cockroach, which adds new challenges and combat dynamics, such as having the ability to block your attacks.  Larger world, richer biomes: More spaces to build, explore, and survive in— Brookhollow Park is nearly as big as the entire backyard from the first game, packed with new secrets around every corner, from snack bars and toppled ice cream carts to long-forgotten edges of the park.  Community driven evolution: We’re building with you, and every update will be more meaningful and shaped by player feedback, with a public roadmap to keep you in the loop that we will share when Game Preview launches on July 29.  Combat 2.0 – Whether you’re flying solo or in full squad mode, new combat mechanics like dodging and smarter enemy behavior make every fight more intense—and more satisfying to survive.  Grounded 2 is launching on July 29 across PC and Xbox Series X|S consoles in early access on July 29, 2025, with a $29.99 price tag. Xbox Game Pass subscribers will be gaining the title at launch for no extra cost as well.
  • Recent Achievements

    • Reacting Well
      BlakeBringer earned a badge
      Reacting Well
    • Reacting Well
      Lazy_Placeholder earned a badge
      Reacting Well
    • Dedicated
      Epaminombas earned a badge
      Dedicated
    • Veteran
      Yonah went up a rank
      Veteran
    • First Post
      viraltui earned a badge
      First Post
  • Popular Contributors

    1. 1
      +primortal
      472
    2. 2
      +FloatingFatMan
      265
    3. 3
      ATLien_0
      234
    4. 4
      snowy owl
      224
    5. 5
      Edouard
      174
  • Tell a friend

    Love Neowin? Tell a friend!