How to Write Pseudocode Algorithm for CAPE Computer Science IA/SBA


You're still here? Good! Because now the challenge really begins. After coming up with a logical solution to your problem - your narrative - you must now put that in a format that is more programmer-friendly.

The pseudocode is an alternative to the flowchart, and a good one too. Even though the flowchart is more standardized than the pseudocode method, it is much harder to modify and needs specialized software to make designing one not a major pain... plus, they just take up too much pages anyway. With that out of the way, let's look at how to get that psedocode popping!

First thing first ... I'm going to tell you to resist the urge to write statements using C-like syntax or any other language's sytax. The purpose of the psuedocode is to write instructions that a programmer can take up and translate into the code of any programming language s/he chooses.

Next thing to note is that each line of your pseudocode should represent one instruction. This simplifies reading the algorithm and hence the conversion process to code will be simpler. Example, supposed you needed to calculate the sum of two user-input numbers and output the answer:

Declare sum, num1, num2 as integer

Write "Enter two numbers: "

Read num1, num2

sum = num1 + num2

Write "The sum is: ", sum

Even though there is no universal standard to writing pseudocode, everyone seems to agree on the keywords to use and how to use them. Keywords are usually capitalized (Read, Write) or written in caps (READ, WRITE). Some of the keywords used include Read, Write, Declare etc. Some keywords must be paired with other keywords and also with an 'end-tag' keyword which signifies the end of that keyword's particular occurence, example: If...Then/Endif, Repeat/Until, While...Do/Endwhile, For...Do/Endfor, Do/While.

When writing pseudocode, proper programming style must always be practised. This involves indenting code to highlight hierarchy. Code between the selection, sequence and iteration constructs must always be indented. Example:

For count= 1 to 3 Do

If num[count] = 0 Then

num[count] = num[count] + 2

Endif

sum = sum + num[count]

Endfor

In summary:

* Keep statements language independent

* Write only one statement in each line

* Capitalize or ALL-CAPS keywords

* Add end-tags where necessary

* Indent to show hierarchy

Now that you have an idea of some of the key rules to follow when translating your narrative to pseudocode, go have a look at the Pseudocode page from the IA Sample! You'll see specific examples of how you can write structures, function prototypes, functions, FILEs, and all the other constructs needed to make a Grade 1 IA.

After that's been completed, it's time to move on to coding the solution in C. Stay tuned to see how you can go about doing that.

Jase-Omeileo West

Author,

Computer Science for CAPE Examinations: UNIT 1 and

Computer Science for CAPE Examinations: UNIT 2

#computerscience #computerscienceforcapeexaminationunit1 #internalassessment #pseudocode #cape #sba #algorithm #ia

Featured Posts
Recent Posts
Search By Tags
No tags yet.
Follow Us
  • Facebook Classic
  • YouTube App Icon

| capecomputerscience@gmail.com | Kingston, Jamaica

  • White YouTube Icon
  • w-facebook
  • White Instagram Icon