Download presentation
Presentation is loading. Please wait.
1
Sequential Structures
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
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.