teach-ict.com logo

THE education site for computer science and ICT

2. Input and output

By default, once a program starts, it will run its commands without asking the user for information or confirmation. And while it will store the results of any calculations it makes, programs will not inform the user of the results unless a command to do so is included in the software.

We often want the program to wait for user input. After all, word processing software that does not allow the user to type anything in is not useful for much, and nobody would buy accounting software that works out your taxes but does not tell you what is owed.

Input

If you want your program to ask the user for information, you will need to know how to use input commands. In pseudocode, this is done with the USERINPUT keyword. For example:

username USERINPUT("Enter your username")

This will ask the user to input data with the prompt "Enter your username". When they do, the "username" variable will be set to whatever they typed.

Output

Similarly, when you want your program to provide the user with information, use the pseudocode keyword OUTPUT. For example:

myVariable 1700

OUTPUT myVariable

This sets the value of the variable myVariable to 1700, then outputs that to the user.

Challenge see if you can find out one extra fact on this topic that we haven't already told you

Click on this link: What is an input command?