Ads

More Examples for Pseudocodes

Here are some basic examples for Pseudocodes.

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

Read num1 , num2
Set multi to num1*num2
Write multi

Example 2: Write pseudo code that tells a user that the number they entered is not a 5 or a 6.

Read isfive If(isfive = 5)
Write "your number is 5" Else if (isfive = 6)Write "your number is 6"
Else
Write "your number is not 5 or 6"

Example 3: Write pseudo code to print all multiples of 5 between 1 and 100 (including both 1 and 100).

Set x to 1
While(x < 20)
write x x = x*5

Example 4: Write pseudo code that will count all the even numbers up to a user defined stopping point.

For example, say we want to see the first 5 even numbers starting from 0. well, we know that evens numbers are 0, 2, 4, etc. The first 5 even numbers are 0, 2, 4, 6, 8. The first 8 even numbers are 0, 2, 4, 6, 8 ,10 ,12, 16

Read count
Set x to 0;
While(x < count)
Set even to even + 2
x = x + 1
write even

Example 5: Write pseudo code that reads in three numbers and writes them all in sorted order.

Read num1, num2, num3
If (num1 < num2)
If(num2 < num3)
Write num1 , num2, num3
Else
If(num3 < num1)
Write num3, num1, num2
Else
Write num1, num3, num2
else
If(num1 < num3)
Write num2 , num1, num3
Else
If(num3 < num2)
Write num3, num2, num1
Else
Write num2, num3, num1


     


Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

buttons=(Accept !) days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !