PseudoCode Examples For Beginners – Programming, Pseudocode Example, C# Programming Example
Pseudocode Examples

PseudoCode Examples For Beginners

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

Example 1:

“Hello World!” A simple program that displays. It is often used to show the syntax of the language.

In this pseudocode, we have used the “OUTPUT” word to print the string Hello, world! on our screen.

Example 2: Pseudocode to add two numbers.

In this example, the user is asked to enter two integers. Then, the sum of these two integers is calculated and displayed on the screen.

Example 3: Pseudocode to average of two numbers.

In this example, the user is asked to enter two integers. Then, the average of these two integers is calculated and displayed on the screen.

Example 4: Pseudocode to calculate area and perimeter of rectangle.

Pseudocode is a kind of structured english for describing algorithms. It allows the designer to focus on the logic of the algorithm without being distracted by details of language syntax. But in this post we will use the C style syntax.

Example 5: Pseudocode to calculate the area of square.

Example 6: Pseudocode to find the greatest of two numbers.

Example 7: Pseudocode to find the greatest of three numbers.

Example 8: Write pseudo code that reads two numbers and multiplies them together and print out their product.

Example 9: Write pseudo code that tells a user that the number they entered is not a 10 or a 20.

Solution 2:

Example 10: Write pseudo code that performs the following: Ask a user to enter a number. If the number is between 0
and 10, write the word blue. If the number is between 10 and 20, write the word red. if the number is between
20 and 30, write the word green. If it is any other number, write that it is not a correct color option.

More..

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.