Pseudocode — with examples

Anna Ikoki
2 min readJan 10, 2023

A pseudocode is a step-wise way to describe a computer program in spoken human language. You can use sentences, loops, conditionals, variables, flowcharts, or graphical and other expressions.

Example: A pseudocode for a weather App that returns the current weather and forecast for a given location

Type I: Declarative pseudocode - sets conditions to give required results.

Begin 
Location is converted into geographic coordinates.
Weather data is retrieved for geographic coordinates.
Weather data is displayed for the user.
End

Type II: Imperative pseudocode - step-by-step instruction on how to get required results.

Begin
Location submitted by user is location name or ZIP code.
Accept location from user input of either location name or ZIP code.
Call OpenWeather's Geocoding API to convert location data into geographic coordinates.
Call OpenWeather's Current Weather Data API.
Send geographic coordinates to OpenWeather.
Call OpenWeather's Daily Forecast 16 Days API.
Resend geographic coordinates.
Parse JSON returned by the APIs to extract current weather and forecast data.
Return current weather and forecast.
Display current weather and forecast to the user.
End

Type III: Comprehensive pseudocode - a combination of declarative(in bold) and imperative pseudocode(in unbold)

** Begin **

Location submitted by user is location name or ZIP code.
Accept location from user input of either location name or ZIP code.

**…

--

--