**What is Pseudocode**

Pseudocode is a compact and informal high-level description of a program using the conventions of a programming language, but intended more for humans.

Pseudocode is not an actual programming language. So it cannot be compiled into an executable program. It uses short terms or simple English language syntaxes to write code for programs before it is actually converted into a specific programming language.

And there is no pseudocode standard syntax and so at times it becomes slightly confusing when writing Pseudocode and so let us understand pseudo code with an example.

**INPUT**– indicates a user will be inputting something**OUTPUT**– indicates that an output will appear on the screen**WHILE**– a loop (iteration that has a condition at the beginning)**FOR**– a counting loop (iteration)**REPEAT – UNTIL**– a loop (iteration) that has a condition at the end**IF – THEN – ELSE**– a decision (selection) in which a choice is made- any instructions that occur inside a selection or iteration are usually indented

### Some Keywords That Should be Used

For looping and selection, The keywords that are to be used include

- Do While…EndDo;
- Do Until…Enddo;
- Case…EndCase;
- If…Endif;
- Call … with (parameters);
- Call; Return ….; Return;
- When;

Always use scope terminators for loops and iteration.As verbs, use the words

- Generate,
- Compute,
- Process, etc.

Words such as

- set,
- reset,
- increment,
- compute,
- calculate,
- add,
- sum,
- multiply,
- … print,
- display,
- input,
- output,
- edit,
- test , etc.

with careful indentation tend to foster desirable pseudocode.

Do not include data declarations in your pseudocode.

**Pseudocode Examples ( Algorithms Examples in Pseudocode )**

There are 18 **pseudocode tutorial **in this post. The **Pseudocode examples** go from **beginner** to **advanced**. You will find a lot of for loop, if else and basics examples. Pseudocode and flowchart examples are in following the post.

**Pseudocode Example 1:** Add Two Numbers.**(Simple Pseudocode Example)**

1 2 3 4 5 6 7 8 9 10 11 |
BEGIN NUMBER s1, s2, sum OUTPUT("Input number1:") INPUT s1 OUTPUT("Input number2:") INPUT s2 sum=s1+s2 OUTPUT sum END |

**Pseudocode Example 2:** Calculate Area and Perimeter of Rectangle **(Simple Pseudocode Example)**

1 2 3 4 5 6 7 8 9 10 11 |
BEGIN NUMBER b1,b2,area,perimeter INPUT b1 UNPUT b2 area=b1*b2 perimeter=2*(b1+b2) OUTPUT alan OUTPUT perimeter END |

**Pseudocode Example 3: **Find Area and Perimeter of a Square (**Simple Pseudocode Example**)

1 2 3 4 5 6 7 8 9 10 |
BEGIN NUMBER len, area,perimeter INPUT len area = len*len perimeter = len*4 OUTPUT area OUTPUT perimeter END |

**Pseudocode Example 4:** Find Area Of Circle using Radius **(Simple Pseudocode Example)**

1 2 3 4 5 6 7 8 |
BEGIN NUMBER r, area INPUT r area=3.14*r*r OUTPUT area END |

**Pseudocode Example 5:** Find Perimeter Of Circle using Radius **(Simple Pseudocode Example)**

1 2 3 4 5 6 7 8 |
BEGIN NUMBER r, perimeter INPUT r perimeter=2*3.14*r OUTPUT perimeter END |

**Pseudocode Example 6:** Calculate sales taxes **(Simple Pseudocode Example)**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
BEGIN NUMBER price, tax, taxRate, total OUTPUT "Enter Product Price" INPUT price OUTPUT "Enter tax rate amoung 1 and 100" OKU taxRate tax= price* taxRate/100 total= price + tax OUTPUT "Product tax="+tax OUTPUT "Product total price ="+total END |

**Pseudocode Example 7:** Solve Quadratic Equation (**Pseudocode If Else Example)**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
BEGIN NUMBER a, b, c, d, x1, x2 INPUT a,b,c d = b^2-4ac IF (d >= 0) THEN x1 = (-b+√d)/2a yada x1 = (-b+d^(1/2)/2a x2 = (-b-√d)/2a yada x2 = (-b-d^(1/2)/2a OUTPUT "ROOT 1:"+x1 OUTPUT "ROOT 2:"+x2 ELSE IF (d == 0) THEN x1=x2= -b/2a OUTPUT "ROOT 1:"+x1 OUTPUT "ROOT 2:"+x2 ELSE OUTPUT "There is no real root" ENDIF END |

**Pseudocode Example 8: **issue for driver licence (**Pseudocode If Else Example)**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
BEGIN NUMBER age INPUT "Enter your age for driving licence" OUTPUT age IF age>=16 THEN OUTPUT "You can take driving licence" ELSE OUTPUT "You can't take driving licence" ENDIF END |

**Pseudocode Example 9:** Check a Number is Positive or Negative (**Pseudocode If Else Example)**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
BEGIN NUMBER num OUTPUT "Enter a Number" OKU num IF num>0 THEN OUTPUT "Entered number is positive" ELSE IF num <0 THEN OUTPUT "Entered number is negative" ELSE OUTPUT "Entered number is zero" ENDIF END |

**Pseudocode Example 10:** Find the biggest of three (3) Numbers (**Pseudocode If Else Example)**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
BEGIN NUMBER num1,num2,num3 INPUT num1 INPUT num2 INPUT num3 IF num1>num2 AND num1>num3 THEN OUTPUT num1+ "is higher" ELSE IF num2 > num3 THEN OUTPUT num2 + "is higher" ELSE OUTPUT num3+ "is higher" ENDIF END |

**Pseudocode Example 11:** Print Numbers from 1 to 100. (**Pseudocode For Loop Example)**

1 2 3 4 5 6 7 8 9 10 |
BEGIN NUMBER counter FOR counter = 1 TO 100 STEP 1 DO OUTPUT counter ENDFOR END |

**Pseudocode Example 12:** Find Sum of Natural Numbers (1 to 100). (**Pseudocode For Loop Example)**

1 2 3 4 5 6 7 8 9 10 11 12 |
BEGIN NUMBER counter, sum=0 FOR counter=1 TO 100 STEP 1 DO sum=sum+counter ENDFOR OUTPUT sum END |

**Pseudocode Example 13:** Read 50 numbers and find their sum and average. (**Pseudocode For Loop Example)**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
BEGIN NUMBER counter, sum=0, num FOR counter=1 TO 50 STEP counter DO OUTPUT "Enter a Number" INPUT num sum=sum+num ENDFOR OUTPUT sum END |

**Pseudocode Example 14:** Read 10 numbers and find sum of even numbers. (**Pseudocode For Loop Example)**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
BEGIN NUMBER counter, sum=0, num FOR counter=1 TO 10 STEP 1 DO OUTPUT "Enter a Number" INPUT num IF num % 2 == 0 THEN sum=sum+num ENDIF ENDFOR OUTPUT sum END |

**Pseudocode Example 15:** Find the sum of all elements of array. (**Pseudocode For Loop Example)**

1 2 3 4 5 6 7 8 9 10 11 12 |
BEGIN NUMBER i=0, n=5, sum=0 ARRAY numbers={65,45,10,7,125} FOR i=0 TO n-1 STEP 1 DO sum = sum + numbers[i] ENDFOR OUTPUT "Sum of numbers in the array"+sum END |

**Pseudocode Example 16:** Calculate square of a number **(Simple Pseudocode Example)**

**Alternative 1:**

1 2 3 4 5 6 7 8 9 10 11 12 |
BEGIN NUMBER num, result OUTPUT "Enter a number for calculate the power of the number" INPUT num result=num*num OUTPUT "Power of the Number:" + result END |

**Alternative 2:**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
BEGIN NUMBER num, result=0,counter OUTPUT "Enter a number for calculate the power of the number" INPUT num FOR counter=0 TO num-1 STEP 1 DO result +=num ENDFOR OUTPUT "Power of the Number:" + result END |

**Pseudocode Example 17:** Calculate the Square Root of a Number (**Pseudocode For Loop Example)**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
BEGIN NUMBER root=1, counter=0,num OUTPUT "Enter a number for calculate the root" INPUT num WHILE sayac < sayi+1 THEN i=i+1 root=(num/root+root)/2 END WHILE OUTPUT root END |

**Pseudocode Example 18:** Swap two variables with using a temporary variable **(Simple Pseudocode Example)**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
BEGIN NUMBER a,b,c a=10, b=20 OUTPUT "Value of a :"+a OUTPUT "Value of b :"+b c=a a=b b=c OUTPUT "Value of a :"+a OUTPUT "Value of b :"+b END |

**Pseudocode Example 19:** Swap two variables without using a temporary variable **(Simple Pseudocode Example)**

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
BEGIN NUMBER a,b a=10, b=20 OUTPUT "Value of a :"+a OUTPUT "Value of b :"+b a=a+b b=a-b a=a-b OUTPUT "Value of a :"+a OUTPUT "Value of b :"+b END |

**Pseudocode Example 20:** Print Numbers from 1 to n. (**Pseudocode For Loop Example)**

1 2 3 4 5 6 7 8 9 10 |
BEGIN NUMBER counter,n INPUT n FOR counter = 1 TO n STEP 1 DO OUTPUT counter ENDFOR END |

**Pseudocode Example 21:** Calculate the Sum and Average of n Number. (**Pseudocode For Loop Example)**

1 2 3 4 5 6 7 8 9 10 11 12 |
BEGIN NUMBER counter,n,sum,avg INPUT n FOR counter = 1 TO n STEP 1 DO sum=sum+counter ENDFOR avg=sum/n OUTPUT "Sum of numbers :"+sum OUTPUT "Average of numbers :"+avg END |

**Pseudocode Example 22:** Design the algorithm and flowchart that finds and display the larger of the two numbers given different from each other.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
BEGIN Number n1,n2 Input n1 Input n2 IF (n1>n2) THEN OUTPUT(n1+" is higher") ELSE IF(n2>n1) OUTPUT(n2+" is higher") ELSE OUTPUT("n1=n2") END IF END |

**Pseudocode Example 23:** Perform the application that calculates the area of the triangle whose height and base length entered by the keyboard.

1 2 3 4 5 6 7 8 9 10 11 12 13 |
BEGIN Number b,h ,area Input b Input h area=(b*h)/2 OUTPUT (Area of Triangle is "+area) END |

**Pseudocode Example 24: **The voltage (V) between the poles of a conductor is equal to the product of the current (I) passing through the conductor and the resistance (R) present on the conductor. It’s demonstrated by the V = I * R formula.

What is the algorithm of the program that calculates the voltage between the poles of the conductor by using the formula according to the current and resistance values entered by the user.

1 2 3 4 5 6 7 8 9 |
BEGIN Number i,r,v Input i Input r v=i*r OUTPUT (v) END |

**Pseudocode Example 25: **What is the algorithm that the number entered by the user from the keyboard fully divided if it is divided into 3 and 5 .

1 2 3 4 5 6 7 8 |
BEGIN Number num Input num IF(num%3==0 AND num%5==0) OUTPUT(num+ " is divided into 3 and 5") END |

**Pseudocode Examples 26:** What is the algorithm that finds and shows on the screen that the water is in the form of solid, liquid or gaseous according to the temperature?

1 2 3 4 5 6 7 8 9 10 11 12 |
BEGIN Number temp Input temp IF(temp<=0) OUTPUT("solid state") ELSE IF(temp<100) OUTPUT("liquid state") ELSE OUTPUT("gaseous state") END |

**Pseudocode Examples 27: **While calculating the wage of a worker at a factory, these criterias are complied;

If the worker has worked less than 40 hours, the wage is calculated by multiplying the hours worked and the hourly wage, if the employee has worked for 40 hours or more, the hours worked calculated as 2 hours. What is the algorithm that prints the amount to be paid according to this information?

1 2 3 4 5 6 7 8 9 10 11 12 13 |
BEGIN Number hour,fee,total INPUT(hour) INPUT(fee) IF(hour<40) total=hour*fee ELSE IF(hour>=40) total=hour*2*fee END IF OUTPUT(total) END |

**Pseudocode Examples 28:** Program to Find GCD of Two Numbers

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
BEGIN NUMBER n1 , n2 , gcd = 1, i OUTPUT "Enter first Number:" INPUT n1 OUTPUT "Enter second Number:" INPUT n2 FOR i = 1; i <= n1 && i <= n2; ++i THEN IF n1 % i == 0 && n2 % i == 0 THEN gcd = i END IF END FOR OUTPUT " G.C.D of "+n1+"and "+n1+" is "+ gcd END |

**Pseudocode Examples 29: **The LCM of two integers `n1` and `n2` is the smallest positive integer that is perfectly divisible by both `n1` and `n2` (without a remainder)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
BEGIN NUMBER n1 , n2 , lcm; OUTPUT "Enter first Number:"; INPUT n1 OUTPUT "Enter second Number:"; INPUT n2 lcm = (n1 > n2) ? n1 : n2; WHILE (true) THEN IF (lcm % n1 == 0 && lcm % n2 == 0) THEN OUTPUT "The LCM of "+n1+"and "+n2+" is "+ lcm; BREAK WHILE; END IF ++lcm; END WHILE END |

**Examples 30:** Simple if else example

1 2 3 4 5 6 |
If student's grade is greater than or equal to 60 Print "passed" else Print "failed" |

**Examples 31:** Alternative Pseudocode Example

1 2 3 4 5 6 7 8 9 10 11 |
Set total to zero Set grade counter to one While grade counter is less than 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. |

**Examples 32**:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
Initialize total to zero Initialize counter to zero Input the first grade while the user has not as yet entered the sentinel add this grade into the running total add one to the grade counter input the next grade (possibly the sentinel) if the counter is not equal to zero set the average to the total divided by the counter print the average else print 'no grades were entered' |

**Examples 33**: Student passed and failured in pseudocode

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
initialize passes to zero initialize failures to zero initialize student to one while student counter is less than or equal to ten input the next exam result if the student passed add one to passes else add one to failures add one to student counter print the number of passes print the number of failures if eight or more students passed print "raise tuition" |

**Examples 34:** Pseudocode of Bubble sort technique

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
Set n to number of records to be sorted repeat flag = false; for counter = 1 to n-1 do if key[counter] > key[counter+1] then swap the records; set flag = true; end if end do n = n-1; until flag = false or n=1 |

**OR the same can be expressed more concisely in words as below**

1 2 3 4 5 6 7 8 9 10 11 |
repeat set a flag to False for each pair of keys if the keys are in the wrong order then swap the keys set the flag to True end if next pair until flag is not set. |

Thanks.

can the pseudocode program be executed in html through notepad?

if not then please suggest where can i try this code program

Pseudocode is not a Real program. It is an approach of programming. You can write working program with programming language as Java, php, Python etc.

This post will help you about diffrence of pseudocode from programming languages.

https://www.code4example.com/pseudocode/pseudocode-to-calculate-area-and-perimeter-of-rectangle/#

nadkhulaaaaaaaa

Foe future referencing, Is Mike the Last name or first name? Kindly provide full reference

Mike Marcus

[…] More.. […]

[…] You may also like: Pseudocode Examples […]