Pseudocode

mamakat0mamakat0 Member Posts: 6 ■□□□□□□□□□
Could someone help me to understand what a pseudocode is? I am taking programming concepts and the class started out with that and I am lost.
I would appreciate the help.
Thank you.

Comments

  • WebmasterWebmaster Admin Posts: 10,292 Admin
    Simply put it's code that doesn't adhere to a particular programming language, syntax, or architecture, but makes it easier to discuss what needs to be done.

    Tip: if you need to find the explanation/definition for a particular world use Google.com and prefix the keyword with "define:" (without the quotes).

    For example: http://www.google.com/search?q=define:pseudocode
  • mamakat0mamakat0 Member Posts: 6 ■□□□□□□□□□
    Could you give me an example of one?
    Thank you.
  • WebmasterWebmaster Admin Posts: 10,292 Admin
    Well, you could take a Visual Basic loop and replace the = > < and other signs by plain English words and you have what you could consider psuedo code.

    vb code:
    Dim unanswered As Int32 = 0
           For i = 0 To Exam.Questions.Length - 1
                If Exam.Questions(i).Answered = False Then unanswered += 1
           Next
    

    psuedocode:
    "Record total number of unanswered questions by checking for each question in Questions collection of Exam if question is answered."

    Probably not a great example. I'll ask JDMurray if he can give his 2 cents in this topic. I never gave it much thought and I don't know if there's a standard, but I assume there are at least unwritten rules/guidelines.

    What also may help: other words for psuedo are: fake, simulated, artificial, pretend.
  • mamakat0mamakat0 Member Posts: 6 ■□□□□□□□□□
    Thank you very much.
  • JDMurrayJDMurray Admin Posts: 13,078 Admin
    Webmaster just about nailed the explanation. Psuedocode is a written language that's used to teach humans logic algorithms and is not intended to be compiled or interpreted by a computer. There is no official standard for pseudocode, so use whatever style is the clearest explanation of what idea you are trying to teach. The simplest is probably a list of logical tasks:
    GET the file name
    CHECK if the file EXISTS
    IF the file EXISTS THEN 
      OPEN the file
    ELSE 
      CREATE the file
    ENDIF
    
    You can also use a generic pseudocode that can be translated into any other computer language, such as:
    LOOP 1 TO 10
      CALL FUNCTION DisplayValue ARG1=LOOPCOUNTER
      INCREMENT LOOPCOUNTER
    END LOOP
    
    The operators in pseudocode are usually names rather than symbols (for example, "NOT EQUALS" rather than "!=" or "<>") that can be translated to any other language using a substitution chart.

    For further reading: Pseudocode article in Wikipedia
  • mamakat0mamakat0 Member Posts: 6 ■□□□□□□□□□
    Thank you. I think I understand it now.
Sign In or Register to comment.