Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Q: swith-case in pseudocode??

  • 10-11-2004 4:15pm
    #1
    Closed Accounts Posts: 5


    Can anyone tell me how to describe swith-case in pseudocode?

    Many thanks.


Comments

  • Registered Users, Registered Users 2 Posts: 21,264 ✭✭✭✭Hobbes


    ???

    Don't you mean Switch case? If you know what switch case does just write pseudo code which will explain what you want. Which part are you having trouble with?


  • Registered Users, Registered Users 2 Posts: 1,481 ✭✭✭satchmo


    I think he's having problems with the part that says "Assignment 1" :confused:


  • Registered Users, Registered Users 2 Posts: 27,370 ✭✭✭✭GreeBo


    without really knowing what you are trying to say its hard to help, so try give more info.
    but I presume it will be the same as if you were describing a bunch of if/else statements and then describe what each case can be...


  • Registered Users, Registered Users 2 Posts: 7,468 ✭✭✭Evil Phil


    http://java.sun.com/docs/books/tutorial/java/nutsandbolts/switch.html explains the concept quite well, has some coding tips and source code.


  • Registered Users, Registered Users 2 Posts: 1,865 ✭✭✭Syth


    I don't really see what the problem is. Pseudo code is a piece of piss. You basically just make up the syntax as you go along. There is no formal definition of pseudo code.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 191 ✭✭Trine


    There's no strict conventions to writing pseudocode. When you're writing a note to yourself you don't bother making sure the grammar is perfect, and it's the same with pseudocode, it's shorthand programming. So a simple switch statement might look like:

    ...
    switch (var1)
    {
    case 1:
    print "Option 1"
    break

    case 2:
    print "Option 2"
    break

    default :
    print "Invalid"
    break

    }
    ...

    So just leave out any obvious programming notation like ';' and the full printf command. You could probably leave out the breaks aswell.

    You're FT228/1 right? Ride on.


  • Closed Accounts Posts: 583 ✭✭✭monkey tennis


    Werl, it wouldn't be a bad idea to get into the habit of making even pseudocode fairly complete - there's bugger all time saved by leaving out semicolons and the like for e.g. I tend to think of pseudocode as a block of regular, fully formatted (or whatever word you'd use) code, only without the rest of the program, the headers, etc etc. I'd definitely type out that above switch example with full printf statements, semicolons, braces, etc. To each their own, I suppose.

    Anyway, for any seasoned programmer, writing code like that is second nature anyway, even pseudocode :)


  • Registered Users, Registered Users 2 Posts: 27,370 ✭✭✭✭GreeBo


    Werl, it wouldn't be a bad idea to get into the habit of making even pseudocode fairly complete - there's bugger all time saved by leaving out semicolons and the like for e.g. I tend to think of pseudocode as a block of regular, fully formatted (or whatever word you'd use) code, only without the rest of the program, the headers, etc etc. I'd definitely type out that above switch example with full printf statements, semicolons, braces, etc. To each their own, I suppose.

    Anyway, for any seasoned programmer, writing code like that is second nature anyway, even pseudocode :)
    my pseudo code is usually some scrawl on a handy scrap of paper

    get the list
    iterate through it
    check for special value
    return list.


Advertisement