Review. October 20, 2006

Size: px
Start display at page:

Download "Review. October 20, 2006"

Transcription

1 Review October 20,

2 A Gentle Introduction to Programming A Program (aka project, application, solution) At a very general level there are 3 steps to program development Determine output Determine input Determine how to process the input to get the output Input Process Output 2

3 Program Development Cycle 1. Analyze: define the problem 2. Design: plan solution 3. Choose interface: Select objects (text boxes buttons, etc) 4. Code: Translate to prog. language 5. Test and debug 6. Document We ll see this in action as we progress through the material 3

4 Algorithms A step-by-step procedure for solving a problem or achieving a goal Consider a recipe Food Cooking Dish 4

5 Pseudocode An abbreviated form of computer code written in natural language Uses structural conventions of programming languages Abstracts away from implementation specifics No language-specific syntax Focus is on steps to solution Pseudocode can be easily translated into programming language (VB) More compact that flowcharts 5

6 Pseudocode Example Program: Add 5 to a number Get number Add 5 to number Display number Note there are a variety of ways to express something in pseudocode 6

7 Start Flowcharts Input Graphical representation of the logical steps to carry out a task logical flow Shows how one task relates to another visually Path taken dependent on input The flowchart originated in computing science No Process A Decision Output Yes Process B End 7

8 Hierarchy Chart Calculator program Add numbers Subtract numbers Divide numbers Multiply numbers 8

9 Four Controls at Design Time Text box To select a control, click on it. Sizing handles will appear when a control is selected. 9

10 The three steps in creating a Visual Basic program: 1. Create the interface; that is, generate, position, and size the objects. 2. Set properties; that is, configure the appearance of the objects. 3. Write the code that executes when events occur. 10

11 Event An event is an action, such as the user clicking on a button Usually, nothing happens in a Visual Basic program until the user does something and generates an event. What happens is determined by statements. 11

12 Examples of Events btnshow.click txtbox.textchanged txtbox.leave General Form: controlname.event 12

13 Structure of an Event Procedure Header Private Sub objectname_event(...) Handles objectname.event statements End Sub (...) is filled automatically with (ByVal sender As System.Object, ByVal e As System.EventArgs) 13

14 Data Types Integer Type Holds integers between ~ -2 billion to 2 billion Double Type Holds whole, or fractional numbers String Type Holds strings of characters Boolean Type Holds true or false 14

15 Three Types of Errors Syntax error E.g. lstbox.items.add(2 + ) Run-time error numvar = & Logic error Average = m + n / 2 15

16 Data Conversion dblvar = CDbl(txtBox.Text) intvar = CInt(txtBox.Text) txtbox.text = CStr(numVar) 16

17 String Properties and Methods "Visual".Length is 6. "Visual".ToUpper is VISUAL. "123 Hike".Length is 8. "123 Hike".ToLower is 123 hike. "a" & " bcd ".Trim & "efg" is abcdefg. hello world".substring(0,2) is he. hello world".indexof( e ) is 1. 17

18 Formatting Output with Zones Use a fixed-width font such as Courier New Divide the characters into zones with a format string (add - for left justification). Dim fmtstr As String = "{0,15:N1}{1,10:C2}{2,8:P0}" lstoutput.items.add(string.format(fmtstr, _ data0, data1, data2)) 18

19 Reading Data from Files Data can be stored in files and accessed with a StreamReader object. We assume that the files are text files (that is, have extension.txt) and have one piece of data per line. Dim readervar As IO.StreamReader readervar = IO.File.OpenText(filespec) 19

20 Getting Input from an Input Dialog Box stringvar = InputBox(prompt, title) filename = InputBox("Enter the name " _ & "of the file containing the " & _ "information.", "Name of File") Title Prompt 20

21 Using a Message Dialog Box for Output MsgBox(prompt, 0, title) MsgBox("Nice try, but no cigar.", 0, _ "Consolation") Note the 0 is a code for the type of button displayed. Title Prompt 21

22 Masked Text Box Similar to an ordinary text box, but has a Mask property that restricts what can be typed into the masked text box. State abbreviation: LL Phone number: Social Security Number: License plate: &&&&&& 22

23 Restricting Behaviour Option Strict: Turn strict typing on (VB will not automatically cast from one type to another) Option Strict On Option Explicit: Must pre-define variables before they are used (using dim) O/w VB uses variant type -- a catchall type Option Explicit On 23

24 Devices for modularity Visual Basic has two devices for breaking problems into smaller pieces: Sub procedures Function procedures 24

25 Sub Procedures Perform one or more related tasks General syntax Sub ProcedureName() statements End Sub Invoked via a call statement: ProcedureName() 25

26 Example lstbox.items.clear() ExplainPurpose() lstbox.items.add("") Sub ExplainPurpose() lstbox.items.add("program displays a sentence") lstbox.items.add("identifying a sum.") End Sub 26

27 Arguments and Parameters Sum(2, 3) arguments parameters Sub Sum(ByVal num1 As Double, ByVal num2 As Double) displayed automatically 27

28 Example with Variables Dim n1 As Integer Dim n2 As Integer Private Sub btnadd_click(...) Handles btnadd.click Sum(n1, n2) End Sub Sub Sum(ByVal num1 As Double, ByVal num2 As Double) DisplayPurpose() lstbox.items.add("the sum of " & num1 & " and " _ & num2 & " is " & (num1 + num2) & "." End Sub 28

29 Passing By Value and By Reference Memory Location 1 This refers to the value of whatever is in this memory location not the location itself ByVal Procedure Parameter This refers to anything stored in this memory location ByRef ProcedureParameter Memory Location 1 Any changes to this, do not effect what is stored in the memory location 1 it s just a copy Any changes to this do effect what is stored in the memory location 1 it s not a copy 29

30 Local & Class-level Variables Dim num As Integer = 4 Private Sub btnone_click(...) Handles btnone_click Dim num As Integer = 4 SetFive() num only exists txtbox.text = CStr(num) within this sub End Sub procedure -- this called it s scope Sub SetFive() Dim num As Integer = 5 End Sub Output: 4 this num is completely unrelated to the one above 30

31 Function Procedures Function procedures (aka user-defined functions) always return one value Function FunctionName(ByVal var1 As Type1, _ ByVal var2 As Type2, _ ) As datatype statement(s) Return expression End Function Call: myvar = FunctionName(var1,var2, ) 31

32 Top-Down Design General problems are at the top of the design Specific tasks are near the end of the design Top-down design and structured programming are techniques to enhance programmers' productivity 32

33 Top-Down Design Criteria 1. The design should be easily readable and emphasize small module size. 2. Modules proceed from general to specific as you read down the chart. 3. The modules, as much as possible, should be single minded. That is, they should only perform a single well-defined task. 4. Modules should be as independent of each other as possible, and any relationships among modules should be specified. 33

34 Detailed Hierarchy Chart 34

35 Structured Programming Control structures in structured programming: Sequences: Statements are executed one after another. Decisions: One of two blocks of program code is executed based on a test for some condition. Loops (iteration): One or more statements are executed repeatedly as long as a specified condition is true. 35

36 Object-Oriented Programming an encapsulation of data and code that operates on the data objects have properties, respond to methods, and raise events. Like a taxonomy Living Things Plants Animals 36

37 ANSI Characters For n between 0 and 255: Chr(n) For a string str, the ANSI code of the first character: Asc(str) EXAMPLES: Chr(65) is "A" Chr(162) is " " Asc("A") is 65 Asc(" 25") is

38 Relational Operators < less than <= less than or equal to > greater than >= greater than or equal to = equal to <> not equal to ANSI values are used to decide order for strings (works left to right in case of equal letters). E.g. AB < BC becase 65 < 66 AB < AC becase 66 < 67 38

39 Logical Operators AND OR NOT ((6<7) AND (10>2)) OR 1=1 A=8; B=10 ((87=A) OR (B>A)) AND (A=8) 39

40 If Statement If condition1 Then action1 ElseIf condition2 Then action2 ElseIf condition3 Then action3 Else action4 End If 40

41 Select Case Block The general form of the Select Case block is Select Case selector Case valuelist1 action1 Case valuelist2 action2 Case Else action of last resort End Select 41

42 Rules for Select Case Case Else (and its action) is optional Each value list contains one or more of the following types of items separated by commas: 1. a literal; 2. a variable; 3. an expression; 4. an inequality sign preceded by Is and followed by a literal, variable, or expression; 5. a range expressed in the form a To b, where a and b are literals, variables, or expressions. 42

43 Flags A flag is a variable that keeps track of whether a certain situation has occurred. The data type most suited to flags is Boolean. 43

44 Example 4: Form The file WORDS.TXT contains words from a spelling bee, one word per line. Count the words and determine whether they are in alphabetical order. 44

45 Example 4: Partial Code Dim word1 As String = "" Dim orderflag As Boolean = True Do While (sr.peek <> -1) word2 = sr.readline wordcounter += 1 If word1 > word2 Then orderflag = False End If word1 = word2 Loop 45

46 More About Flags When flagvar is a variable of Boolean type, the statements If flagvar = True Then and If flagvar = False Then can be replaced by If flagvar Then and If Not flagvar Then 46

47 For Next Loops Used when we know how many times we want the loop to execute A counter controlled loop (this is i below) Dim i As Integer For i = 1 To 5 lsttable.items.add(i & " " & i ^ 2) Next 47

48 Example 2 Control variable Type Decl Start value Stop value Amount to add to index For index As Integer = 0 To n Step s Next lstvalues.items.add(index) 48

49 Do Loops A loop is one of the most important structures in programming. Used to repeat a sequence of statements a number of times. The Do loop repeats a sequence of statements either while or until a certain condition is true. 49

50 Do While Loop Syntax Do While condition statement(s) Loop Condition is tested, If it is True, the loop is run. If it is False, the statements following the Loop statement are executed. These statements are inside the body of the loop and are run if the condition above is True. 50

51 Do Until Loop (Post Test) Syntax Do statement(s) Loop Until condition Loop is executed once and then the condition is tested. If it is False, the loop is run again. If it is True, the statements following the Loop statement are executed. 51

52 Example Dim i As Integer = 1 Do For j As Integer = 10 To 0 _ Step -1 ListBox.Add.Items(j) ListBox.Add.Items(i) Next i += 1 Loop Until i > 10 Output:

Introducing Visual Basic

Introducing Visual Basic Introducing Visual Basic September 13, 2006 Chapter 3 - VB 2005 by Schneider 1 Today Continuing our intro to VB First some housework Chapter 3 - VB 2005 by Schneider 2 Friday Assignment 1 Vote on midterm

More information

Introducing Visual Basic

Introducing Visual Basic Introducing Visual Basic September 11, 2006 Chapter 3 - VB 2005 by Schneider 1 Today Continuing our intro to VB First some housework Chapter 3 - VB 2005 by Schneider 2 Classroom Contract Chapter 3 - VB

More information

Introducing Visual Basic

Introducing Visual Basic Introducing Visual Basic September 8, 2006 Chapter 3 - VB 2005 by Schneider 1 Today Chapter 3 provides a great walkthrough intro to VB We re going to take a detailed look at this today (and pick it up

More information

ADMIN STUFF. Assignment #1 due. Assignment #2. Midterm. Posted to website Due Oct 11. Review session Oct 16 Midterm in class Oct 18 [2 hours long]

ADMIN STUFF. Assignment #1 due. Assignment #2. Midterm. Posted to website Due Oct 11. Review session Oct 16 Midterm in class Oct 18 [2 hours long] TODAY S QUOTE Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are by definition not smart enough to debug it. (Brian Kernighan)

More information

HOW TO DEVELOP A VB APPLICATION

HOW TO DEVELOP A VB APPLICATION REVIEW OF CHAPTER 2 HOW TO DEVELOP A VB APPLICATION Design the Interface for the user Literally draw the GUI Drag buttons/text boxes/etc onto form Determine which events the controls on the window should

More information

Repetition. October 4, Chapter 6 - VB 2005 by Schneider 1

Repetition. October 4, Chapter 6 - VB 2005 by Schneider 1 Repetition October 4, 2006 Chapter 6 - VB 2005 by Schneider 1 Chapter 6 Repetition 6.1 Do Loops 6.2 Processing Lists of Data with Do Loops 6.3 For...Next Loops 6.4 A Case Study: Analyze a Loan Chapter

More information

Chapter 2 Visual Basic, Controls, and Events. 2.1 An Introduction to Visual Basic 2.2 Visual Basic Controls 2.3 Visual Basic Events

Chapter 2 Visual Basic, Controls, and Events. 2.1 An Introduction to Visual Basic 2.2 Visual Basic Controls 2.3 Visual Basic Events Chapter 2 Visual Basic, Controls, and Events 2.1 An Introduction to Visual Basic 2.2 Visual Basic Controls 2.3 Visual Basic Events 1 2.1 An Introduction to Visual Basic 2010 Why Windows and Why Visual

More information

REVIEW OF CHAPTER 1 1

REVIEW OF CHAPTER 1 1 1 REVIEW OF CHAPTER 1 Trouble installing/accessing Visual Studio? 2 Computer a device that can perform calculations and make logical decisions much faster than humans can Computer programs a sequence of

More information

Repetition Structures

Repetition Structures Repetition Structures There are three main structures used in programming: sequential, decision and repetition structures. Sequential structures follow one line of code after another. Decision structures

More information

FINAL CHAPTER. Web Applications

FINAL CHAPTER. Web Applications 1 FINAL CHAPTER Web Applications WEB PROGRAMS The programs in this chapter require the use of either Visual Web Developer 2010 (packaged with this textbook) or the complete version of Visual Studio 2010.

More information

Microsoft Visual Basic 2015: Reloaded

Microsoft Visual Basic 2015: Reloaded Microsoft Visual Basic 2015: Reloaded Sixth Edition Chapter Three Memory Locations and Calculations Objectives After studying this chapter, you should be able to: Declare variables and named constants

More information

Introduction to Visual Basic and Visual C++ Arithmetic Expression. Arithmetic Expression. Using Arithmetic Expression. Lesson 4.

Introduction to Visual Basic and Visual C++ Arithmetic Expression. Arithmetic Expression. Using Arithmetic Expression. Lesson 4. Introduction to Visual Basic and Visual C++ Arithmetic Expression Lesson 4 Calculation I154-1-A A @ Peter Lo 2010 1 I154-1-A A @ Peter Lo 2010 2 Arithmetic Expression Using Arithmetic Expression Calculations

More information

VARIABLES. 1. STRINGS Data with letters and/or characters 2. INTEGERS Numbers without decimals 3. FLOATING POINT NUMBERS Numbers with decimals

VARIABLES. 1. STRINGS Data with letters and/or characters 2. INTEGERS Numbers without decimals 3. FLOATING POINT NUMBERS Numbers with decimals VARIABLES WHAT IS A VARIABLE? A variable is a storage location in the computer s memory, used for holding information while the program is running. The information that is stored in a variable may change,

More information

Visual Basic.NET. 1. Which language is not a true object-oriented programming language?

Visual Basic.NET. 1. Which language is not a true object-oriented programming language? Visual Basic.NET Objective Type Questions 1. Which language is not a true object-oriented programming language? a.) VB.NET b.) VB 6 c.) C++ d.) Java Answer: b 2. A GUI: a.) uses buttons, menus, and icons.

More information

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming

Intro to Programming. Unit 7. What is Programming? What is Programming? Intro to Programming Intro to Programming Unit 7 Intro to Programming 1 What is Programming? 1. Programming Languages 2. Markup vs. Programming 1. Introduction 2. Print Statement 3. Strings 4. Types and Values 5. Math Externals

More information

Tutorial 03 understanding controls : buttons, text boxes

Tutorial 03 understanding controls : buttons, text boxes Learning VB.Net Tutorial 03 understanding controls : buttons, text boxes Hello everyone welcome to vb.net tutorials. These are going to be very basic tutorials about using the language to create simple

More information

Language Fundamentals

Language Fundamentals Language Fundamentals VBA Concepts Sept. 2013 CEE 3804 Faculty Language Fundamentals 1. Statements 2. Data Types 3. Variables and Constants 4. Functions 5. Subroutines Data Types 1. Numeric Integer Long

More information

Petros: A Multi-purpose Text File Manipulation Language

Petros: A Multi-purpose Text File Manipulation Language Petros: A Multi-purpose Text File Manipulation Language Language Reference Manual Joseph Sherrick js2778@columbia.edu June 20, 2008 Table of Contents 1 Introduction...................................................

More information

Microsoft Visual Basic 2005: Reloaded

Microsoft Visual Basic 2005: Reloaded Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 3 Variables, Constants, Methods, and Calculations Objectives After studying this chapter, you should be able to: Declare variables and named

More information

Ordinary Differential Equation Solver Language (ODESL) Reference Manual

Ordinary Differential Equation Solver Language (ODESL) Reference Manual Ordinary Differential Equation Solver Language (ODESL) Reference Manual Rui Chen 11/03/2010 1. Introduction ODESL is a computer language specifically designed to solve ordinary differential equations (ODE

More information

Unit 4. Lesson 4.1. Managing Data. Data types. Introduction. Data type. Visual Basic 2008 Data types

Unit 4. Lesson 4.1. Managing Data. Data types. Introduction. Data type. Visual Basic 2008 Data types Managing Data Unit 4 Managing Data Introduction Lesson 4.1 Data types We come across many types of information and data in our daily life. For example, we need to handle data such as name, address, money,

More information

20. VB Programming Fundamentals Variables and Procedures

20. VB Programming Fundamentals Variables and Procedures 20. VB Programming Fundamentals Variables and Procedures 20.1 Variables and Constants VB, like other programming languages, uses variables for storing values. Variables have a name and a data type. Array

More information

DATABASE AUTOMATION USING VBA (ADVANCED MICROSOFT ACCESS, X405.6)

DATABASE AUTOMATION USING VBA (ADVANCED MICROSOFT ACCESS, X405.6) Technology & Information Management Instructor: Michael Kremer, Ph.D. Database Program: Microsoft Access Series DATABASE AUTOMATION USING VBA (ADVANCED MICROSOFT ACCESS, X405.6) AGENDA 3. Executing VBA

More information

OBJECT ORIENTED SIMULATION LANGUAGE. OOSimL Reference Manual - Part 1

OBJECT ORIENTED SIMULATION LANGUAGE. OOSimL Reference Manual - Part 1 OBJECT ORIENTED SIMULATION LANGUAGE OOSimL Reference Manual - Part 1 Technical Report TR-CSIS-OOPsimL-1 José M. Garrido Department of Computer Science Updated November 2014 College of Computing and Software

More information

Programming Language 2 (PL2)

Programming Language 2 (PL2) Programming Language 2 (PL2) 337.1.1 - Explain rules for constructing various variable types of language 337.1.2 Identify the use of arithmetical and logical operators 337.1.3 Explain the rules of language

More information

DroidBasic Syntax Contents

DroidBasic Syntax Contents DroidBasic Syntax Contents DroidBasic Syntax...1 First Edition...3 Conventions Used In This Book / Way Of Writing...3 DroidBasic-Syntax...3 Variable...4 Declaration...4 Dim...4 Public...4 Private...4 Static...4

More information

( ) 1.,, Visual Basic,

( ) 1.,, Visual Basic, ( ) 1. Visual Basic 1 : ( 2012/2013) :. - : 4 : 12-14 10-12 2 http://www.institutzamatematika.com/index.ph p/kompjuterski_praktikum_2 3 2 / ( ) 4 90% 90% 10% 90%! 5 ? 6 "? : 7 # $? - ( 1= on 0= off ) -

More information

VISUAL BASIC 6.0 OVERVIEW

VISUAL BASIC 6.0 OVERVIEW VISUAL BASIC 6.0 OVERVIEW GENERAL CONCEPTS Visual Basic is a visual programming language. You create forms and controls by drawing on the screen rather than by coding as in traditional languages. Visual

More information

Visual Basic distinguishes between a number of fundamental data types. Of these, the ones we will use most commonly are:

Visual Basic distinguishes between a number of fundamental data types. Of these, the ones we will use most commonly are: Chapter 3 4.2, Data Types, Arithmetic, Strings, Input Data Types Visual Basic distinguishes between a number of fundamental data types. Of these, the ones we will use most commonly are: Integer Long Double

More information

Good Variable Names: dimensionone, dimension1 Bad Variable Names: dimension One, 1dimension

Good Variable Names: dimensionone, dimension1 Bad Variable Names: dimension One, 1dimension VB Scripting for CATIA V5: Email Course by Emmett Ross Lesson #4 - CATIA Macro Variable Naming Variables make up the backbone of any programming language. Basically, variables store information that can

More information

SNS COLLEGE OF ENGINEERING,

SNS COLLEGE OF ENGINEERING, SNS COLLEGE OF ENGINEERING, COIMBATORE Department of Computer Science and Engineering QUESTION BANK(PART A) GE8151 - PROBLEM SOLVING AND PYTHON PROGRAMMING TWO MARKS UNIT-I 1. What is computer? Computers

More information

variables programming statements

variables programming statements 1 VB PROGRAMMERS GUIDE LESSON 1 File: VbGuideL1.doc Date Started: May 24, 2002 Last Update: Dec 27, 2002 ISBN: 0-9730824-9-6 Version: 0.0 INTRODUCTION TO VB PROGRAMMING VB stands for Visual Basic. Visual

More information

Chapter 6 Repetition. 6.1 Do Loops 6.2 For...Next Loops 6.3 List Boxes and Loops

Chapter 6 Repetition. 6.1 Do Loops 6.2 For...Next Loops 6.3 List Boxes and Loops Chapter 6 Repetition 6.1 Do Loops 6.2 For...Next Loops 6.3 List Boxes and Loops 1 6.1 Do Loops Pretest Form of a Do Loop Posttest Form of a Do Loop 2 Do Loops A loop is one of the most important structures

More information

Input/Output. Introduc3on

Input/Output. Introduc3on Input/Output CE 311 K - Introduc0on to Computer Methods Daene C. McKinney Forma9ng Numbers Input From Files Output To Files Input Boxes Introduc3on 1 Forma6ng Numbers Display numbers in familiar formats

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

VB FUNCTIONS AND OPERATORS

VB FUNCTIONS AND OPERATORS VB FUNCTIONS AND OPERATORS In der to compute inputs from users and generate results, we need to use various mathematical operats. In Visual Basic, other than the addition (+) and subtraction (-), the symbols

More information

Lecture Transcript While and Do While Statements in C++

Lecture Transcript While and Do While Statements in C++ Lecture Transcript While and Do While Statements in C++ Hello and welcome back. In this lecture we are going to look at the while and do...while iteration statements in C++. Here is a quick recap of some

More information

Review for Exam 2. IF Blocks. Nested IF Blocks. School of Business Eastern Illinois University. Represent computers abilities to make decisions

Review for Exam 2. IF Blocks. Nested IF Blocks. School of Business Eastern Illinois University. Represent computers abilities to make decisions School of Business Eastern Illinois University Review for Exam 2 - IF Blocks - Do s - Select Case Blocks (Week 10, Friday 3/21/2003) Abdou Illia, Spring 2003 IF Blocks 2 Represent computers abilities to

More information

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual

Contents. Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual Jairo Pava COMS W4115 June 28, 2013 LEARN: Language Reference Manual Contents 1 Introduction...2 2 Lexical Conventions...2 3 Types...3 4 Syntax...3 5 Expressions...4 6 Declarations...8 7 Statements...9

More information

Reserved Words and Identifiers

Reserved Words and Identifiers 1 Programming in C Reserved Words and Identifiers Reserved word Word that has a specific meaning in C Ex: int, return Identifier Word used to name and refer to a data element or object manipulated by the

More information

Higher Computing Science Software Design and Development - Programming Summary Notes

Higher Computing Science Software Design and Development - Programming Summary Notes Higher Computing Science Software Design and Development - Programming Summary Notes Design notations A design notation is the method we use to write down our program design. Pseudocode is written using

More information

Repetition Structures

Repetition Structures Repetition Structures Chapter 5 Fall 2016, CSUS Introduction to Repetition Structures Chapter 5.1 1 Introduction to Repetition Structures A repetition structure causes a statement or set of statements

More information

REPETITION CONTROL STRUCTURE LOGO

REPETITION CONTROL STRUCTURE LOGO CSC 128: FUNDAMENTALS OF COMPUTER PROBLEM SOLVING REPETITION CONTROL STRUCTURE 1 Contents 1 Introduction 2 for loop 3 while loop 4 do while loop 2 Introduction It is used when a statement or a block of

More information

Condition-Controlled Loop. Condition-Controlled Loop. If Statement. Various Forms. Conditional-Controlled Loop. Loop Caution.

Condition-Controlled Loop. Condition-Controlled Loop. If Statement. Various Forms. Conditional-Controlled Loop. Loop Caution. Repetition Structures Introduction to Repetition Structures Chapter 5 Spring 2016, CSUS Chapter 5.1 Introduction to Repetition Structures The Problems with Duplicate Code A repetition structure causes

More information

Getting Started. Office Hours. CSE 231, Rich Enbody. After class By appointment send an . Michigan State University CSE 231, Fall 2013

Getting Started. Office Hours. CSE 231, Rich Enbody. After class By appointment send an  . Michigan State University CSE 231, Fall 2013 CSE 231, Rich Enbody Office Hours After class By appointment send an email 2 1 Project 1 Python arithmetic Do with pencil, paper and calculator first Idle Handin Help room 3 What is a Computer Program?

More information

Before We Begin. Introduction to Computer Use II. Overview (1): Winter 2006 (Section M) CSE 1530 Winter Bill Kapralos.

Before We Begin. Introduction to Computer Use II. Overview (1): Winter 2006 (Section M) CSE 1530 Winter Bill Kapralos. Winter 2006 (Section M) Topic E: Subprograms Functions and Procedures Wednesday, March 8 2006 CSE 1530, Winter 2006, Overview (1): Before We Begin Some administrative details Some questions to consider

More information

Language Reference Manual

Language Reference Manual ALACS Language Reference Manual Manager: Gabriel Lopez (gal2129) Language Guru: Gabriel Kramer-Garcia (glk2110) System Architect: Candace Johnson (crj2121) Tester: Terence Jacobs (tj2316) Table of Contents

More information

Programming Logic and Design Seventh Edition Chapter 2 Elements of High-Quality Programs

Programming Logic and Design Seventh Edition Chapter 2 Elements of High-Quality Programs Programming Logic and Design Chapter 2 Elements of High-Quality Programs Objectives In this chapter, you will learn about: Declaring and using variables and constants Assigning values to variables [assignment

More information

Revision for Final Examination (Second Semester) Grade 9

Revision for Final Examination (Second Semester) Grade 9 Revision for Final Examination (Second Semester) Grade 9 Name: Date: Part 1: Answer the questions given below based on your knowledge about Visual Basic 2008: Question 1 What is the benefit of using Visual

More information

Variable A variable is a value that can change during the execution of a program.

Variable A variable is a value that can change during the execution of a program. Declare and use variables and constants Variable A variable is a value that can change during the execution of a program. Constant A constant is a value that is set when the program initializes and does

More information

Instructor s Notes Programming Logic Printing Reports. Programming Logic. Printing Custom Reports

Instructor s Notes Programming Logic Printing Reports. Programming Logic. Printing Custom Reports Instructor s Programming Logic Printing Reports Programming Logic Quick Links & Text References Printing Custom Reports Printing Overview Page 575 Linking Printing Objects No book reference Creating a

More information

Function: function procedures and sub procedures share the same characteristics, with

Function: function procedures and sub procedures share the same characteristics, with Function: function procedures and sub procedures share the same characteristics, with one important difference- function procedures return a value (e.g., give a value back) to the caller, whereas sub procedures

More information

Overview About KBasic

Overview About KBasic Overview About KBasic The following chapter has been used from Wikipedia entry about BASIC and is licensed under the GNU Free Documentation License. Table of Contents Object-Oriented...2 Event-Driven...2

More information

UNIT- 3 Introduction to C++

UNIT- 3 Introduction to C++ UNIT- 3 Introduction to C++ C++ Character Sets: Letters A-Z, a-z Digits 0-9 Special Symbols Space + - * / ^ \ ( ) [ ] =!= . $, ; : %! &? _ # = @ White Spaces Blank spaces, horizontal tab, carriage

More information

Part 4 - Procedures and Functions

Part 4 - Procedures and Functions Part 4 - Procedures and Functions Problem Solving Methodology... 2 Top Down Design... 2 Procedures and Functions... 5 Sub Procedures... 6 Sending Parameters to a Sub Procedure... 7 Pass by Value... 8 Pass

More information

Fundamentals of Programming (Python) Getting Started with Programming

Fundamentals of Programming (Python) Getting Started with Programming Fundamentals of Programming (Python) Getting Started with Programming Ali Taheri Sharif University of Technology Some slides have been adapted from Python Programming: An Introduction to Computer Science

More information

Objectives. Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments

Objectives. Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments Basics Objectives Introduce the core C# language features class Main types variables basic input and output operators arrays control constructs comments 2 Class Keyword class used to define new type specify

More information

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA

TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA 1 TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson, and instructor materials prepared

More information

Language Reference Manual simplicity

Language Reference Manual simplicity Language Reference Manual simplicity Course: COMS S4115 Professor: Dr. Stephen Edwards TA: Graham Gobieski Date: July 20, 2016 Group members Rui Gu rg2970 Adam Hadar anh2130 Zachary Moffitt znm2104 Suzanna

More information

Chapter 3: Programming with MATLAB

Chapter 3: Programming with MATLAB Chapter 3: Programming with MATLAB Choi Hae Jin Chapter Objectives q Learning how to create well-documented M-files in the edit window and invoke them from the command window. q Understanding how script

More information

LECTURE 5 Control Structures Part 2

LECTURE 5 Control Structures Part 2 LECTURE 5 Control Structures Part 2 REPETITION STATEMENTS Repetition statements are called loops, and are used to repeat the same code multiple times in succession. The number of repetitions is based on

More information

Chapter 1: A First Program Using C#

Chapter 1: A First Program Using C# Chapter 1: A First Program Using C# Programming Computer program A set of instructions that tells a computer what to do Also called software Software comes in two broad categories System software Application

More information

Outline. Program development cycle. Algorithms development and representation. Examples.

Outline. Program development cycle. Algorithms development and representation. Examples. Outline Program development cycle. Algorithms development and representation. Examples. 1 Program Development Cycle Program development cycle steps: Problem definition. Problem analysis (understanding).

More information

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible)

Multiple Choice (Questions 1 13) 26 Points Select all correct answers (multiple correct answers are possible) Name Closed notes, book and neighbor. If you have any questions ask them. Notes: Segment of code necessary C++ statements to perform the action described not a complete program Program a complete C++ program

More information

Chapter 2. Designing a Program. Input, Processing, and Output Fall 2016, CSUS. Chapter 2.1

Chapter 2. Designing a Program. Input, Processing, and Output Fall 2016, CSUS. Chapter 2.1 Chapter 2 Input, Processing, and Output Fall 2016, CSUS Designing a Program Chapter 2.1 1 Algorithms They are the logic on how to do something how to compute the value of Pi how to delete a file how to

More information

Sub Programs. To Solve a Problem, First Make It Simpler

Sub Programs. To Solve a Problem, First Make It Simpler Sub Programs To Solve a Problem, First Make It Simpler Top Down Design Top Down Design Start with overall goal. Break Goal into Sub Goals Break Sub Goals into Sub Sub Goals Until the Sub-Sub Sub-Sub Sub-Sub

More information

Programming Fundamentals - A Modular Structured Approach using C++ By: Kenneth Leroy Busbee

Programming Fundamentals - A Modular Structured Approach using C++ By: Kenneth Leroy Busbee 1 0 1 0 Foundation Topics 1 0 Chapter 1 - Introduction to Programming 1 1 Systems Development Life Cycle N/A N/A N/A N/A N/A N/A 1-8 12-13 1 2 Bloodshed Dev-C++ 5 Compiler/IDE N/A N/A N/A N/A N/A N/A N/A

More information

CSCI 1061U Programming Workshop 2. C++ Basics

CSCI 1061U Programming Workshop 2. C++ Basics CSCI 1061U Programming Workshop 2 C++ Basics 1 Learning Objectives Introduction to C++ Origins, Object-Oriented Programming, Terms Variables, Expressions, and Assignment Statements Console Input/Output

More information

VBA Handout. References, tutorials, books. Code basics. Conditional statements. Dim myvar As <Type >

VBA Handout. References, tutorials, books. Code basics. Conditional statements. Dim myvar As <Type > VBA Handout References, tutorials, books Excel and VBA tutorials Excel VBA Made Easy (Book) Excel 2013 Power Programming with VBA (online library reference) VBA for Modelers (Book on Amazon) Code basics

More information

CPSC 203 Extra review and solutions

CPSC 203 Extra review and solutions CPSC 203 Extra review and solutions Multiple choice questions: For Questions 1 6 determine the output of the MsgBox 1) x = 12 If (x > 0) Then s = s & "a" s = s & "b" a. a b. b c. s d. ab e. None of the

More information

Text Input and Conditionals

Text Input and Conditionals Text Input and Conditionals Text Input Many programs allow the user to enter information, like a username and password. Python makes taking input from the user seamless with a single line of code: input()

More information

COP 1220 Introduction to Programming in C++ Course Justification

COP 1220 Introduction to Programming in C++ Course Justification Course Justification This course is a required first programming C++ course in the following degrees: Associate of Arts in Computer Science, Associate in Science: Computer Programming and Analysis; Game

More information

Assessment - Unit 3 lessons 16-21

Assessment - Unit 3 lessons 16-21 Name(s) Period Date Assessment - Unit 3 lessons 16-21 1. Which of the following statements about strings in JavaScript is FALSE? a. Strings consist of a sequence of concatenated ASCII characters. b. Strings

More information

Flow Chart. The diagrammatic representation shows a solution to a given problem.

Flow Chart. The diagrammatic representation shows a solution to a given problem. low Charts low Chart A flowchart is a type of diagram that represents an algorithm or process, showing the steps as various symbols, and their order by connecting them with arrows. he diagrammatic representation

More information

DEVELOPING OBJECT ORIENTED APPLICATIONS

DEVELOPING OBJECT ORIENTED APPLICATIONS DEVELOPING OBJECT ORIENTED APPLICATIONS By now, everybody should be comfortable using form controls, their properties, along with methods and events of the form class. In this unit, we discuss creating

More information

Chapter 3. More Flow of Control. Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley

Chapter 3. More Flow of Control. Copyright 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 3 More Flow of Control Overview 3.1 Using Boolean Expressions 3.2 Multiway Branches 3.3 More about C++ Loop Statements 3.4 Designing Loops Slide 3-3 Flow Of Control Flow of control refers to the

More information

ENGR 101 Engineering Design Workshop

ENGR 101 Engineering Design Workshop ENGR 101 Engineering Design Workshop Lecture 2: Variables, Statements/Expressions, if-else Edgardo Molina City College of New York Literals, Variables, Data Types, Statements and Expressions Python as

More information

COMP 202 Recursion. CONTENTS: Recursion. COMP Recursion 1

COMP 202 Recursion. CONTENTS: Recursion. COMP Recursion 1 COMP 202 Recursion CONTENTS: Recursion COMP 202 - Recursion 1 Recursive Thinking A recursive definition is one which uses the word or concept being defined in the definition itself COMP 202 - Recursion

More information

COMS 469: Interactive Media II

COMS 469: Interactive Media II COMS 469: Interactive Media II Agenda Review Data Types & Variables Decisions, Loops, and Functions Review gunkelweb.com/coms469 Review Basic Terminology Computer Languages Interpreted vs. Compiled Client

More information

CA4003 Compiler Construction Assignment Language Definition

CA4003 Compiler Construction Assignment Language Definition CA4003 Compiler Construction Assignment Language Definition David Sinclair 2017-2018 1 Overview The language is not case sensitive. A nonterminal, X, is represented by enclosing it in angle brackets, e.g.

More information

CS 115 Lecture 8. Selection: the if statement. Neil Moore

CS 115 Lecture 8. Selection: the if statement. Neil Moore CS 115 Lecture 8 Selection: the if statement Neil Moore Department of Computer Science University of Kentucky Lexington, Kentucky 40506 neil@cs.uky.edu 24 September 2015 Selection Sometime we want to execute

More information

An overview about DroidBasic For Android

An overview about DroidBasic For Android An overview about DroidBasic For Android from February 25, 2013 Contents An overview about DroidBasic For Android...1 Object-Oriented...2 Event-Driven...2 DroidBasic Framework...2 The Integrated Development

More information

Programming for Engineers Iteration

Programming for Engineers Iteration Programming for Engineers Iteration ICEN 200 Spring 2018 Prof. Dola Saha 1 Data type conversions Grade average example,-./0 class average = 23450-67 893/0298 Grade and number of students can be integers

More information

JScript Reference. Contents

JScript Reference. Contents JScript Reference Contents Exploring the JScript Language JScript Example Altium Designer and Borland Delphi Run Time Libraries Server Processes JScript Source Files PRJSCR, JS and DFM files About JScript

More information

Type Conversion. and. Statements

Type Conversion. and. Statements and Statements Type conversion changing a value from one type to another Void Integral Floating Point Derived Boolean Character Integer Real Imaginary Complex no fractional part fractional part 2 tj Suppose

More information

do fifty two: Language Reference Manual

do fifty two: Language Reference Manual do fifty two: Language Reference Manual Sinclair Target Jayson Ng Josephine Tirtanata Yichi Liu Yunfei Wang 1. Introduction We propose a card game language targeted not at proficient programmers but at

More information

VLC : Language Reference Manual

VLC : Language Reference Manual VLC : Language Reference Manual Table Of Contents 1. Introduction 2. Types and Declarations 2a. Primitives 2b. Non-primitives - Strings - Arrays 3. Lexical conventions 3a. Whitespace 3b. Comments 3c. Identifiers

More information

Quick Reference Guide

Quick Reference Guide SOFTWARE AND HARDWARE SOLUTIONS FOR THE EMBEDDED WORLD mikroelektronika Development tools - Books - Compilers Quick Reference Quick Reference Guide with EXAMPLES for Basic language This reference guide

More information

Model Viva Questions for Programming in C lab

Model Viva Questions for Programming in C lab Model Viva Questions for Programming in C lab Title of the Practical: Assignment to prepare general algorithms and flow chart. Q1: What is a flowchart? A1: A flowchart is a diagram that shows a continuous

More information

Program Fundamentals

Program Fundamentals Program Fundamentals /* HelloWorld.java * The classic Hello, world! program */ class HelloWorld { public static void main (String[ ] args) { System.out.println( Hello, world! ); } } /* HelloWorld.java

More information

Loops! Loops! Loops! Lecture 5 COP 3014 Fall September 25, 2017

Loops! Loops! Loops! Lecture 5 COP 3014 Fall September 25, 2017 Loops! Loops! Loops! Lecture 5 COP 3014 Fall 2017 September 25, 2017 Repetition Statements Repetition statements are called loops, and are used to repeat the same code mulitple times in succession. The

More information

CSC180 Homework 3 (Due November 29, 2018, 6 pages)

CSC180 Homework 3 (Due November 29, 2018, 6 pages) CSC180 Homework 3 (Due November 29, 2018, 6 pages) NAME: Write your answer in the blank line next to each question. 1. What will be displayed by the following program when the button is clicked? Dim s

More information

3. Can every Do-Loop loop be written as a For-Next loop? Why or why not? 4. Name two types of files that can be opened and used in a VB program.

3. Can every Do-Loop loop be written as a For-Next loop? Why or why not? 4. Name two types of files that can be opened and used in a VB program. CE 311 K Fall 005 Second Exam - Examples Answers at the bottom. 1. What are two categories of flow control structures?. Name three logical operators in Visual Basic (VB). 3. Can every Do-Loop loop be written

More information

DATA AND ABSTRACTION. Today you will learn : How to work with variables How to break a program down Good program design

DATA AND ABSTRACTION. Today you will learn : How to work with variables How to break a program down Good program design DATA AND ABSTRACTION Today you will learn : How to work with variables How to break a program down Good program design VARIABLES Variables are a named memory location Before you use a variable you must

More information

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program Objectives Chapter 2: Basic Elements of C++ In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates

More information

Chapter 2: Basic Elements of C++

Chapter 2: Basic Elements of C++ Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types Discover how a program evaluates

More information

Java+- Language Reference Manual

Java+- Language Reference Manual Fall 2016 COMS4115 Programming Languages & Translators Java+- Language Reference Manual Authors Ashley Daguanno (ad3079) - Manager Anna Wen (aw2802) - Tester Tin Nilar Hlaing (th2520) - Systems Architect

More information

EnableBasic. The Enable Basic language. Modified by Admin on Sep 13, Parent page: Scripting Languages

EnableBasic. The Enable Basic language. Modified by Admin on Sep 13, Parent page: Scripting Languages EnableBasic Old Content - visit altium.com/documentation Modified by Admin on Sep 13, 2017 Parent page: Scripting Languages This Enable Basic Reference provides an overview of the structure of scripts

More information

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction Chapter 2: Basic Elements of C++ C++ Programming: From Problem Analysis to Program Design, Fifth Edition 1 Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers

More information