1 / 7

Sequential Structures

Sequential Structures. N201 Introduction to Programming Concepts Dept. of Computer and Information Science. Goals. Understand why a sequence structure is used How to create sequence structure. Sequential Logic.

Download Presentation

Sequential Structures

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Sequential Structures N201 Introduction to Programming Concepts Dept. of Computer and Information Science

  2. Goals • Understand why a sequence structure is used • How to create sequence structure

  3. Sequential Logic • Early programs used sequential logic. That is, Step A happened before Step B. Step B happened before Step C, etc. • Sequential programs are easy to write, but lack flexibility. (decisions and loops)

  4. Sequential Structures • A series of statements • Executed in order • No branching • A jump in the flow of execution

  5. Sequential Structures • Start – where the program begins • Input – data to be used for the program • Step One, Step Two, etc. – the sequence of the program until it finishes • No deviation

  6. Sequential Statements • Welcome Message • Ask for data • Input name, address, city, favorite color data • Output data • Write name, address, city, favorite color message

  7. Sequential Structures • var strUserName = ""; • // user's name, this is a STRING • var strUserCity = ""; • // user's city, this is a STRING • var intNumLetters = 0; • // number of letters in user's first name, this is an INTEGER • var strMessage = "" • // output to the user, this is a STRING • strUserName = window.prompt("What is your name?"); • //this is asking for the user's name • strUserCity = window.prompt("Where do you live?"); • //this is asking what city does the user live in • strMessage = ("Hello, "); strMessage += (strUserName.toUpperCase()); • //this puts the user's name into uppercase letters • strMessage += (". You live in "); • strMessage += (strUserCity.toUpperCase()); • //this puts the user's city into uppercase letters • window.alert(strMessage); • //this is the message given to the user • intNumLetters = strUserName.length; • // output to the user • window.alert("There are " +intNumLetters+" letters in your first name."); • //this is a string method, it is counting the number of letters in the user's name • //this tells the user how many letters that user has in their name

More Related