The building blocks of programming

Every program in the world has been built by using the three basic building blocks (sequential, branching, and looping instructions). 

Enter Your Password!

Image from book

password$ = “”
WHILE password$ <> “open”
  PROMPT “Enter your password”; password$
  IF password$ = “open” THEN
    NOTICE “Welcome to the FBI’s secret computer network”
  ELSE
    NOTICE “Try again”
  END IF
WEND
END
Image from book
 

you can break this program in the following parts:

Sequential instructions

Image from book

password$ = “”
WHILE password$ <> “open”
  PROMPT “Enter your password”; password$
  IF password$ = “open” THEN
    NOTICE “Welcome to the FBI’s secret computer
        network”
  ELSE
    NOTICE “Try again”
  END IF
WEND
END
Image from book
 

Branching instruction

Image from book

password$ = “”
WHILE password$ <> “open”
  PROMPT “Enter your password”; password$
  IF password$ = “open” THEN
    NOTICE “Welcome to the FBI’s secret computer
        network”
  ELSE
    NOTICE “Try again”
  END IF
WEND
END
Image from book
 

Looping instruction

Image from book

password$ = “”
WHILE password$ <> “open”
  PROMPT “Enter your password”; password$
  IF password$ = “open” THEN
    NOTICE “Welcome to the FBI’s secret computer
        network”
  ELSE
    NOTICE “Try again”
  END IF
WEND
END
Image from book
 

You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

AddThis Social Bookmark Button

Leave a Reply



eXTReMe Tracker