Pseudocode Introduction - Our first keywords
Pseudocode is just one method of planning our programs, and getting ready for our first steps into programming.
This guide focusses on our first two keywords: OUTPUT and USERINPUT and in this article you will find out what they are used for.
Now, OUTPUT is the first keyword learnt by any programmer. No matter what programming language you're learning, the first thing you learn will be how to say 'Hello World!' through your computer's console (on the screen). OUTPUT is the pseudocode equivalent, and it is used like this:
OUTPUT "Hello World"
Now, you don't always have to write hello world. You could write anything, but what is important to remember is that OUTPUT, outputs something to the user. Now its important to notice two things here: first is the fact I used capital letters when writing my keyword OUTPUT, and secondly that our text we are wanting to output is surrounded by quotation marks.
When we write speech in our Literacy or English lessons, we would always use quotation marks to show when someone is speaking. When we are outputting to our user, we use quotation marks to show that we are 'speaking' to our user. Also, by using capital letters in our keywords, we highlight the keywords we are using, and this makes our pseudocode easier to read.
Now that we know how to output something to the user, we are going to look at how a user inputs something to our program. But first, we need to know how to use variables, otherwise we wouldn't be able to save or use our user's input.
Think of variables like a box. We store things inside boxes, and that is how we use variables but in this case we give our box a name. For this example, I am going to call my box, animal, and in it I am going to store the user's favourite animal using our keyword OUTPUT and a brand new keyword: USERINPUT.
OUTPUT "What is your favourite animal" animal = USERINPUT
Here you can see we have used both of our keywords. OUTPUT is used to ask the user what their favourite animal is. By using USERINPUT, we are showing that we expect the user to input something here (this is usually done via typing on a keyboard). We are saving this input into the variable animal.
Notice that the variable name is not in capital letters, this is because there are certain rules we need to follow when it comes to variable names:
Don't capitalise your variable names
Don't include any keywords in your variable names
Don't have any spaces in your variable names (the computer can't understand spaces)
Don't start variable names with a number
By keeping to these simple variable name rules in your pseudocode, you will already have brilliant habits when it comes to practical programming on a computer, and it will show that you have a great understanding of how your pseudocode would work in a practical environment.
The keywords we have covered in this guide are OUTPUT and USERINPUT.
USERINPUT is used to show that the user is inputting something to our program.
OUTPUT is used to show that we are outputting something to the user.