How to Write Pseudocode?

Posted in

How to Write Pseudocode?

Vinay Khatri
Last updated on June 10, 2022

    In this article, we will discuss how to write pseudocode? Continue reading. Pseudocode is a mix of technical terms and common English that facilitates computer programmers to write computer algorithms. Before diving into how to write pseudocode, let’s first discuss what pseudocode is and why we need it.

    What is Pseudocode?

    pseudocode is the plain English representation of a computer program or algorithm, which specifies the flow and operation of the program. It is generally used to represent the structural flow of a program, and it is not associated with any specific programming language. The same quality makes it a perfect tool to represent algorithms for various problems. Some significant points you need to know about pseudocode are:

    • It is not a programming language.
    • It is just a learning and reasoning tool, which is used by programmers and developers to underline how to write the actual code.
    • Pseudocode can not be executed or compiled by any compiler , interpreter , or assembler.
    • Unlike programming language code, pseudocode does not follow a strict structure and syntax. Here, the programmer can write the code syntax as he pleases.


    Code to check  if the user entered number is odd or even: C++ Programming

    int main()
    int num;
    cout<<"Enter a number";
        cout<<"Even Number";
        cout<<"Odd Number";


    num :INPUT “Enter a number”
    IF num MOD 2 ===0
        print “Even Number”
        print “Odd Number”

    Why Use Pseudocode?

    Before building anything, we first need to create a blueprint that describes all the methods, strategies, flow of the structure, and the resulting interface of the actual project. Developers and programmers follow the same concept before they start writing the code for their projects, but here instead of the blueprint, the developer uses pseudocode to represent what approach and structure the actual program will follow. The syntax of every programming language varies, which makes it hard to understand the implemented algorithm by studying the code. But pseudocode provides a solution for this. With the help of pseudocode, we can write an algorithm using simple English. It allows a specific programming language developer or programmer could to understand the logic of the program and implement it in a specific programming language. With pseudocode, we deal with the actual logic and the basic operations provided by every programming language . While writing pseudocode, we focus on the atomic process and methods provided by every programing language, and based on those operations and methods we try to build an algorithm. When we write pseudocode for an algorithm, there are several operations, operators, and methods that we can use. In the section below, we mention only those which are common to every programming language.

    How to Write Pseudocode?

    As pseudocode does not follow a strict systematic or standard way of being written, so don’t think of writing pseudocode as a strict rule. However, there are some standard conventions that every programmer follows while writing one. These are:

    • Use capital words for reserved commands or keywords, for example, if you are writing IF…ELSE statements then make sure IF and ELSE be in capital letters.
    • Write only one statement per line.
    • Use indentation for the block body. It keeps the body of every component isolated and indenting different pieces of each block will indicate that those pieces of pseudocode go under a less intended section.
    • Be specific while writing a statement, use plain English to provide a particular description.

    Pseudocode for Different Statements

    Operators :

    1. Assignment Operator:

    =, <- or :=

    2. Comparison Operator:

    == , !=, <, >, <= , and >=

    3. Arithmetic Operator:

    +,-, *, /, MOD(%)

    4. Logical Operator:

    AND, NOT and OR

    5. Sum, Product:

    ? ?

    Special Keyword:

    1. START: To begin the pseudocode.
    2. INPUT: Take input from the user.
    3. PRINT: To print the output on the screen.
    4. READ/GET: Input format while reading data from the file.
    5. SET, INIT: Initialize a value.
    6. INCREMENT, BUMP: Increase the value of the variable, equivalent to a++.
    7. DECREMENT: Decrease the value of the variable, equivalent to a--.
    8. COMPUTE, CALCULATE, DETERMINE: To calculate the expression result.

    Conditional Statements:


    IF condition
        THEN if body


    IF condition THEN
        if body
        else body

    if…else if….else

    IF condition statement THEN
        if body
    ELSE IF condition THEN
        else if statement
        else body

    Example1 :

    age = INPUT : “Enter your age”
    IF age is greater than 18
        PRINT “adult”
        PRINT “Under age”

    Example 2:

    age = INPUT : “Enter Your age”
    IF age is equal to 18 THEN
        PRINT “under check”
    ELSE IF age is greater than 18
        PRINT “Give entry”
        PRINT “under age”


    for loops:

    FOR initial_value TO end_value
        for body


    FOR i -> 0 to 20
        PRINT i

    while loop

    WHILE condition
        while body


    i : 0
    WHILE i  <= 20
        PRINT i


    FUNTION function_name(parameters)
        function body
        RETURN value


    FUNTION add( para1, para2 )
        result: para1+para2
        RETURN result

    Write the FizzBuzz Algorithm Using pseudocode

    FizzBuzz is a standard coding and interview problem, in which we write a code to print Fizz, Buzz, and FizzBuzz when the multiple of 3 and 5 occurs. The problem states:

    • Write a code that prints each number from 1 to 30 in a new line.
    • Print "Fizz" if the number is the multiple of 3.
    • Print "Buzz" if the number is a multiple of 5.
    • For a number that is multiple of both 3 and 5 print “FizzBuzz.”

    FizzBuzz Pseudocode

    num : 1
    FOR num -> 1 to 20
        IF num MOD 15 ===0
            PRINT “FizzBuzz”
        ELSE IF num MOD 3 ===0
            PRINT “Fizz”
        ELSE IF num MOD 5===0
            PRINT “Buzz”
            PRINT num

    Equivalent Python Code:

    for num in range(1, 21):
        if num % 15 ==0:
        elif num %3 ==0:
        elif num %5==0:

    Advantage of Pseudocode

    There are several advantages of leveraging pseudocode while developing computer programs and solving problems. Some of the most important ones are:

    • Increases the code readability.
    • Provides the best way to write algorithms.
    • More than specific syntax focuses on the program logic.
    • The best approach to represent how the actual program will be written.

    How to Write Pseudocode as a Beginner

    If you are a complete beginner in the programming world, just getting started with a new programming language, heard of Pseudocode, and wondering what this syntax is and how to write it. Don't worry it is not a mandatory syntax it's just a good coding practice, that many developers use before they get started on a project. Pseudocode is mostly used in a project algorithm discussion when developers prefer the common syntax of pseudocode to write the algorithm rather than writing it in a Programming language.

    Pseudocode Examples for Beginners

    Let's discuss another pseudocode example that is more beginner-friendly. Suppose you need to write a program in C++ that can calculate the area of a rectangle. But before you implement the code in the programing language you want to write its pseudocode. Pseudocode Example to calculate the area of a rectangle

        length = INPUT: "Enter the length of the rectangle"
        width  = INPUT: "Enter the width of the rectangle"
        area = length * width
        OUTPUT area

    Pseudocode to C++ Now let's convert the above pseudocode to the equivalent C++ code.

    #include <iostream>
    using namespace std;
    int main() {
        float length, width, area;
        cout<<"Enter the length of the rectangle: "; cin>>length;
        cout<<"Enter the width of the rectangle: "; cin>>width;
        area = width*length;
        cout<<"The area of the rectangle is "<<area;

    Checkout more pseudocode examples to develop your pseudocode writing skills


    There are no such strict rules to write pseudocode, and thus, the programmer can write it as she wishes, but it should be written in such a manner so that other developers could comprehend the algorithm. All the examples and syntax we have mentioned here are conventional, and generally, most programmer follows the same syntax. If you want, you can modify the code to your liking.

    In the above pseudocode examples, you can notice that for each component end, we use the END word. But if you want, you can replace it with { } curly braces. If you like this article or have any suggestions, please let us know. We hope you learned something new from this. This article presented you with the details of pseudocode and ways to write one. If you wish to learn more, you can buy a course for the same.

    People are also reading:

    Leave a Comment on this Post