• 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

    • Wall cabinet: Fiber connection (1Gbps) Patch panel 2.5Gbps Router A mini PC with Ryzen 5800H CPU and 32GB DDR4 RAM, for network related tools (Portainer, Pi-Hole, Cloudflared, Tailscale, Uptime Kuma, Wetty) A headless server running Proxmox: AMD Ryzen 9 9950X CPU, 96GB DDR5, RTX 3090 24GB GPU, 10Gbps NIC, and a bunch of NVMs, SATA SSDs, HDDs A VM with TrueNAS for backups and media server via Jellyfin, passing through the SATA storage controller A VM with an Ubuntu server acting as a web and a GPU server for AI workloads, and a TeamCity build/deploy agent for my personal projects This setup has evolved many times for the last 2 years, I have not gone completely crazy, yet (I think), but still experimenting, still learning, it is a fun and rewarding experience having a home lab!
    • Microsoft PC Manager 3.17.4.0 (Offline Installer) by Razvan Serea With Microsoft PC Manager, users can easily perform basic computer maintenance and enhance the speed of their devices with just one click. This app offers a range of features, including disk cleanup, startup app management, virus scanning, Windows Update checks, process monitoring, and storage management. Microsoft PC Manager key features: Storage Manager- easily uninstall infrequently used apps, manage large files, perform a cleanup, and set up Storage Sense to automatically clear temporary files. Health Checkup feature -scans for potential problems, viruses, and startup programs to turn off. It helps you identify unnecessary items to remove, optimizing your system's performance. Pop-up Management - block pop-up windows from appearing in apps. Windows Update - scans your system for any pending updates. Startup Apps - enable or disable startup apps on your PC, allowing you to optimize your system's startup performance. Browser Protection - rest assured that harmful programs cannot alter your default browser. Also enables you to change your default browser. Process Management - allows you to conveniently terminate any active process, ensuring optimal system performance and resource utilization. Anti-virus protection - Fully integrated with Windows Security. Safeguard your PC anytime. Quick Steps: Download Microsoft PC Manager Offline Installer (APPX/MSIX) with Adguard Adguard serves as a third-party online service, offering a user-friendly method for directly downloading appx, appxbundle, and msixbundle files from the Microsoft Store. Official download links will be generated for both the app's various versions and its dependency packages. How to download Microsoft PC Manager Offline Installer (APPX/MSIX) 1. Initially, you must find the app URL within the Microsoft Store. Access the Microsoft Store via your browser and search for "Microsoft PC Manager". Once located, copy the app URL, which includes the product ID, either from the address bar or from the provided link below. https://apps.microsoft.com/detail/9PM860492SZD 2. Now paste the app URL into the designated area, then click the check mark button to produce a direct download link. 3. To download, right-click the relevant link and select “Save link as…” from your browser's menu. Occasionally, Microsoft Edge may flag the download as insecure. In such cases, consider utilizing alternative browsers such as Google Chrome or Firefox to successfully complete the download. Microsoft PC Manager is a completely free tool optimized exclusively for use on Windows 10 (version 1809 or newer) and Windows 11. Download: Microsoft PC Manager 3.17.4.0 | from Microsoft Store View: Microsoft PC Manager Home Page Get alerted to all of our Software updates on Twitter at @NeowinSoftware
    • You might want to update to 1TB drive.  They are not very expensive these days, there are plenty of options - simple look I would think you could find a 1TB ssd or even nvme somewhere between 50 and 100 bucks. when I have moved to larger ssds in laptop in the past, you can just connect the drive via usb - image.  Then take the old drive out, put in the new drive and there you go..  If your concerned about how much space you have left this prob your best bet..   
    • I see! Wasn’t aware of that. Even though they started off with desktop app for Mac before Windows. Should be on it’s way soon! 🤞
    • support.microsoft.com/en-us/topic/microsoft-defender-update-for-windows-operating-system-installation-images-1c89630b-61ff-00a1-04e2-2d1f3865450d
  • Recent Achievements

    • First Post
      Johnny Mrkvička earned a badge
      First Post
    • Week One Done
      viraltui earned a badge
      Week One Done
    • One Month Later
      serfegyed earned a badge
      One Month Later
    • Dedicated
      firey earned a badge
      Dedicated
    • Dedicated
      fettermanj earned a badge
      Dedicated
  • Popular Contributors

    1. 1
      +primortal
      627
    2. 2
      ATLien_0
      223
    3. 3
      Michael Scrip
      217
    4. 4
      Xenon
      149
    5. 5
      Steven P.
      139
  • Tell a friend

    Love Neowin? Tell a friend!