Definition of PseudoCode and Its Functions, Structure and Examples

If you are a programmer you must be familiar with the term algorithm. Yes, the algorithm is a sequence of steps to get things done or solve a problem. The algorithm must be needed by every programmer before making a program.

Well, if you already understand what an algorithm is, what about pseudocode? Pseudocode is also an algorithm, the shape is similar to a programming language.

But, keep in mind pseudocode is not a programming language. Almost the same as the flowchart algorithm, but the difference is that the flowchart uses symbols to describe the running process. Check out the article below to better understand what Pseudocode is.

Definition of PseudoCode

Pseudo means imitation and code, which means the code associated with the command written in a programming language or computer language code. If interpreted freely, then pseudocode means imitation or imitation of the programming language code .

Basically, pseudocode is a language that allows programmers to think about a problem that must be solved immediately without having to think about the code or syntax of a particular programming language. In pseudocode there are no rules in writing the syntax. So pseudocode is used to describe the logic in sequence from a program without first thinking about the programming language.

Pseudocode is translated into Indonesian as a fake code. The point is a description of a computer programming algorithm that uses the structural conventions of a programming language, and has the goal of being easily read by humans not by machines. Pseudocode usually does not use elements – details that are not necessary for the needs of human understanding of an algorithm, such as the declaration of variables, code or sub-routine for systems that have specific properties.

Although pseudocode uses the structure of a programming language, it will not follow the writing rules in any programming language. Why is that? Because pseudocode is written just to make it easier for someone to understand an algorithm.

That way, pseudocode is only code that resembles program code, and cannot be understood or understood directly by computer machines. Pseudocode can be processed by a computer machine if it follows the writing rules in a programming language. For example using C, C ++, Pascal, C #, Java, Golang and so on.

PseudoCode function

Pseudocode has a function that is useful to facilitate the writing and mapping of an algorithm. Because basically, a programmer before creating and running a program or application, he must first have an arrangement or have a solution to the problem he will make is usually called an algorithm .

Yes, before making a program, a programmer must know what kind of algorithm he will use to solve the problem. By using pseudocode writing it will also be known as complex as what the program will be made later. Besides that, pseudocode also has other functions. Here are some functions of pseudocode:

  1. Pseudocode has a function as a documentation tool
  2. Pseudocode can make it easy for users to understand and clarify how to solve problems.
  3. Pseudocode can help users in writing an algorithm that will be made.
  4. Pseudocode has a very concise and easy aspect because pseudocode does not depend on a particular system and that is what makes it the main principle of an algorithm.

The purpose of pseudocode itself is that humans, especially programmers, can easily understand compared to using programming languages ​​that are generally used, moreover aspects of pseudocode are relatively concise and do not have dependence on a particular system which is the main principle in an algorithm.

In general, pseudocode is used in the publication of scientific papers or books documenting an algorithm. Pseudocode is also used in planning the development of computer programs to sketch the structure of a program before the actual program is created or written.

Pseudocode does not have any one standard, a program that is still a pseudocode will not be able to run. Pseudocode is arguably similar to skeleton programs or frameworks including dummycode which can be compiled without errors. Flowcharts can also be included as graphically based alternatives to a pseudocode.

PseudoCode structure

In general, the structure of writing pseudocode is divided into 3 parts. The following pseudocode structure:

  1. Title section

This title section contains the algorithm title. Usually this section begins with the word “program”. Then, followed by the name of the algorithm. In general, the name of an algorithm consists of only one word, if the names contained more than one written word are put together. This means that if it consists of more than two words, then sapasi is eliminated.

Here are the rules for writing title names:

  • Title cannot contain spaces. Spaces can be replaced with the character “_” (underscore).
  • Title cannot start with a number.
  • Titles should not use terms that are commonly used as keywords in programming languages.
  • Titles may use uppercase, lowercase letters, and their combinations as long as they do not violate the above rules.
  1. Part description

As the name suggests, this description section is used to define or declare the types of variables that will be used in the algorithmic process. In computer programming itself there are several variables, such as integers, decimals, fractions, and so forth.

  1. The implementation part

This part of the implementation can be said to be the core or main part, which is part of the running of an algorithm. In this section there are a set of algorithmic commands, the commands can also be in the form of sequential, conditional or looping.

Example of PseudoCode

Here are some examples of pseudocode algorithms:

  1. Example of PseudoCode Calculating the Area of ​​a Triangle

A triangle flat has a broad formula which is ΔABC  = ½. pedestal. height , with this area formula you can create a pseudocode algorithm on the area of ​​a triangle, and you need to know the height and base of the triangle.

For example the calculation of the area of ​​a triangle that we will make a pseudocode algorithm. Given a triangle’s flat shape has a base = 20 and a height of 30, what is the area of ​​the triangle?

So, in the pseudocode algorithm language is as follows:

program hitung_luas_segitiga deklarasi var luas,alas,tinggi:integer; algoritma: alas <– 20; tinggi <– 30; luas <– 1/2 * alas * tinggi write(luas)

  1. Example of PseudoCode Calculating Trapezoidal Area

As we know the traveling formula of Trapezoid is K = AB + BC + CD + AD  while the area formula is  L = (AB + CD) xt / 2  . For example in the picture below it is known:

AB = 12
BC = 6
CD = AD = 10
t = 8

So in writing Pseudocode as follows:

program hitung_luas_trapesium deklarasi var luas, ab, cd, t:integer; algoritma: ab <– 12; cd <– 10; t <– 8; luas <– 1/2 * ab * cd * t; write <– luas ;

The above code consists of the title: program hitung_ expanding_trapezium , declaration:  var broad, ab, cd, t: integer; , and the core of the algorithm are:  ab <- 12; cd <- 10; t <- 8; area <- 1/2 * ab * cd * t; .

  1. Example of PseudoCode Calculating the Area of ​​a Circle

The circumference formula and area of ​​a circle are  L = π × d² / 4 = π × r² , while for the circumference of a circle is K = π × d = 2 × π × r , to calculate the diameter of a circle we can calculate it with the formula  D = 2 xr .

To make the Pseudocode Algorithm in calculating the area of ​​a circle we can use the Pascal programming language approach, where the radius of the circle is entered by the user and the results are printed. as follows:

program hitung_luas_lingkaran deklarasi var phi : float; var r,luas:integer; algoritma: phi <– 3.14; read(r); {diinput user} luas <– phi * r *r; write(luas);

  1. Example of PseudoCode Determining Prime Numbers

We know that prime numbers are numbers that are divisible by one and numbers whose numbers are greater than 28 do not have multiples.

Deklarasi Ulang,Jumb,Sisa,Bilangan : Interger Hasil : String Deskripsisi Read (Bilangan) For (ulang = 1 to ulang <=bil.step1) sisa if (sisa=0) THEN jumB  <-jumB+1 Else jumb2) THEN Hasil <-(“Bukan bil prima”) Else Hasil <-(“Bilangan Prima”) Write (Hasil)

  1. Example of PseudoCode Calculating Rectangles

In this case we will calculate the pseudocode with the rectangular formula, the formula for the area of ​​the rectangle is  L = pxl  while the circumferential formula is  K = 2 x (p + l) . In the Pseudocode Algorithm calculates the area of ​​a rectangle, the length and width are entered and the area is displayed.

program hitung_luas_segi_panjang deklarasi var panjang,lebar,luas:integer; algoritma: read(panjang); read(lebar);  luas <– panjang * lebar; write(luas);

Thus this article discusses the understanding of PseudoCode, and the functions and structure of pseudocode, and also examples of pseudocode. Hopefully this article can be useful for you. Thank you 🙂

 

Leave a Comment