Difference between revisions of "Pseudo Code"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(An Exam Question...)
(Exmaples - What Do They Do?)
 
(3 intermediate revisions by the same user not shown)
Line 12: Line 12:
 
* Any other instruction that occurs inside a selection or iteration are usually indented
 
* Any other instruction that occurs inside a selection or iteration are usually indented
  
== Exmaples - What Do They Do? ==
+
== Examples - What Do They Do? ==
 
     Set total to zero
 
     Set total to zero
 
     Set grade counter to one
 
     Set grade counter to one
Line 39: Line 39:
 
* Is there any area of the code that 
is repeated?
 
* Is there any area of the code that 
is repeated?
  
== How To 
Tackle An 
Exam Question ==
+
== How To Tackle An Exam Question ==
 
==== Do It All In A Step By Step Basis.. ====
 
==== Do It All In A Step By Step Basis.. ====
 
==== * Think Logically... ====
 
==== * Think Logically... ====
* What are my inputs, outputs 
and so on?
+
* What are my inputs, outputs and so on?
 
* What is the question asking me?
 
* What is the question asking me?
 
* What are the numbers? Are they integers? Is it an boolean?
 
* What are the numbers? Are they integers? Is it an boolean?
Line 55: Line 55:
 
== An Exam Question... ==
 
== An Exam Question... ==
  
[[File:Pseudocode_(2)-1.png]]
+
[[File:Pseudocode_(2)-1.png|700px]]

Latest revision as of 07:36, 20 June 2019

Back To Basics...

Pseudocode is a simple way of writing programming code in English. Pseudocode is not actual a programming language. It uses short phrases to write code for programs before you actually create it in a specific language (i.e C++). Once you know what the program is about and how it will function, then you can use pseudocode to create statements to achieve the required results for your program.

Common Keywords For Pseudocode…

  • Input = indicates a user will be inputting something into the code
  • Output = indicates that there will be an output from the program
  • While = a loop (until a condition has been met)
  • For = a continuous loop
  • Repeat - Until = a loop that has a condition until the end
  • If - Then - Else = a decision in which a choice is made
  • Any other instruction that occurs inside a selection or iteration are usually indented

Examples - What Do They Do?

    Set total to zero
    Set grade counter to one
    While grade counter is < or equal to ten
    Input the next grade
    Add the grade into the total
    Set the class average to the total divided by ten
    Print the class average.
Another
    REPEAT
    OUTPUT ‘What is the best subject you take?’
    INPUT user inputs the best subject they take
    STORE the user’s input in the answer variable
    IF answer = ‘Computer Science’ THEN
         OUTPUT ‘Of course it is!’
    ELSE
         OUTPUT ‘Try again!’
    UNTIL answer = ‘Computer Science

When You Are Writing You Pseudocode, you have to take into consideration the following…

  • What are all of your inputs?
  • What are all of your outputs?
  • In what order does the code need to be carried out?
  • What decisions need to be made in the code?
  • Is there any area of the code that 
is repeated?

How To Tackle An Exam Question

Do It All In A Step By Step Basis..

* Think Logically...

  • What are my inputs, outputs and so on?
  • What is the question asking me?
  • What are the numbers? Are they integers? Is it an boolean?

Now It Is Your Turn…

Write you own pseudocode for anything that you want. If you are stuck here are a few ideas:

  • How to make a cheese toastie
  • How to get ready in the morning
  • How to warm up a ready meal

An Exam Question...

Pseudocode (2)-1.png