Microsoft Visual Basic 2005: Reloaded
|
|
- Ethan Burke
- 6 years ago
- Views:
Transcription
1 Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 4 Making Decisions in a Program
2 Objectives After studying this chapter, you should be able to: Include the selection structure in pseudocode and in a flowchart Write an If Then Else statement Write code that uses comparison operators and logical operators Create a variable having block-scope Concatenate strings Microsoft Visual Basic 2005: Reloaded, Second Edition 2
3 Objectives (continued) Use the ControlChars.NewLine constant Change the case of a string Determine whether a string contains data Display a message in a message box Include a nested selection structure in pseudocode, a flowchart, and code Microsoft Visual Basic 2005: Reloaded, Second Edition 3
4 Objectives (continued) Code an If/ElseIf/Else selection structure Include a Case selection structure in pseudocode, a flowchart, and code Generate random numbers Microsoft Visual Basic 2005: Reloaded, Second Edition 4
5 The Selection Structure Selection structure (or decision structure): Used to select a path to take based on the outcome of a decision or comparison Condition: The decision to be made Results in a Boolean (True or False) answer Four forms of selection structure: If If/Else If/ElseIf/Else Case Microsoft Visual Basic 2005: Reloaded, Second Edition 5
6 The Selection Structure (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 6
7 Writing Pseudocode for the If and If/Else Selection Structures If selection structure: contains one set of instructions to process when the condition is true If/Else selection structure: Contains two sets of instructions One set is processed when the condition is true The other set is processed when the condition is false True path: path to follow when condition is true False path: path to follow when condition is false Microsoft Visual Basic 2005: Reloaded, Second Edition 7
8 Writing Pseudocode for the If and If/Else Selection Structures (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 8
9 Flowcharting the If and If/Else Selection Structures Selection/repetition symbol: Diamond shape Represents both selection and repetition structures One flowline entering and two flowlines leaving Microsoft Visual Basic 2005: Reloaded, Second Edition 9
10 Flowcharting the If and If/Else Selection Structures (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 10
11 Coding the If and If/Else Selection Structures Microsoft Visual Basic 2005: Reloaded, Second Edition 11
12 Coding the If and If/Else Selection Structures (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 12
13 Coding the If and If/Else Selection Structures (continued) Else clause: an optional part of the If statement Statement block: set of statements terminated by an Else or End If Microsoft Visual Basic 2005: Reloaded, Second Edition 13
14 Comparison Operators Comparison operators (or relational operators): Used as part of the condition in an If statement Most commonly used comparison operators: Equal to: = Greater than: > Greater than or equal to: >= Less than: < Less than or equal to: <= Not equal to: <> Microsoft Visual Basic 2005: Reloaded, Second Edition 14
15 Comparison Operators (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 15
16 Comparison Operators (continued) Comparison operators: Have no order of precedence Are evaluated from left to right in an expression Microsoft Visual Basic 2005: Reloaded, Second Edition 16
17 Comparison Operators (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 17
18 Using Comparison Operators Swapping Numeric Values Pseudocode for a procedure that displays highest and lowest of two numbers: Microsoft Visual Basic 2005: Reloaded, Second Edition 18
19 Using Comparison Operators Swapping Numeric Values (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 19
20 Using Comparison Operators Swapping Numeric Values (continued) Block scope: the scope of a variable created within a block Block-scope variable: can only be used within the statement block in which it was declared Concatenation operator (&): links two strings ControlChars.NewLine constant: Advances the insertion point to the next line Microsoft Visual Basic 2005: Reloaded, Second Edition 20
21 Using Comparison Operators Swapping Numeric Values (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 21
22 Using Comparison Operators Swapping Numeric Values (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 22
23 Using Comparison Operators Swapping Numeric Values (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 23
24 Using Comparison Operators Swapping Numeric Values (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 24
25 Using Comparison Operators Swapping Numeric Values (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 25
26 Using Comparison Operators Example 2 Pseudocode for a procedure to allow the user to display the sum or difference of two numbers: Microsoft Visual Basic 2005: Reloaded, Second Edition 26
27 Using Comparison Operators Example 2 (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 27
28 Using Comparison Operators Example 2 (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 28
29 Using Comparison Operators Example 2 (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 29
30 Using Comparison Operators Example 2 (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 30
31 Using the ToUpper and ToLower Methods String comparisons in Visual Basic are case-sensitive ToUpper method: converts a string to uppercase ToLower method: converts a string to lowercase ToUpper and ToLower can be used to permanently or temporarily convert a variable s contents Microsoft Visual Basic 2005: Reloaded, Second Edition 31
32 Using the ToUpper and ToLower Methods (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 32
33 Using the ToUpper and ToLower Methods (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 33
34 Using the ToUpper and ToLower Methods (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 34
35 Logical Operators Logical operators (or Boolean operators): Used to combine one or more conditions Compound condition: a combination of conditions using logical operator(s) Microsoft Visual Basic 2005: Reloaded, Second Edition 35
36 Logical Operators (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 36
37 Logical Operators (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 37
38 Logical Operators (continued) Truth tables: used to evaluate logical operators in an expression Short-circuit evaluation: an evaluation in which the second condition may not be evaluated And and Or operations always evaluate both conditions AndAlso and OrElse operations do not evaluate second condition if the first condition is false Microsoft Visual Basic 2005: Reloaded, Second Edition 38
39 Logical Operators (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 39
40 Logical Operators (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 40
41 Using the Truth Tables Use And or AndAlso when both conditions must be true to give a true result Use Or or OrElse when one or both conditions must be true to give a true result Use XOr when exactly one condition must be true to give a true result Logical operators are evaluated after arithmetic or comparison operators in an expression Microsoft Visual Basic 2005: Reloaded, Second Edition 41
42 Using the Truth Tables (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 42
43 Using the Truth Tables (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 43
44 Using Logical Operators in an If Then Else Statement Data validation: Verifying that the input data is within the expected range Use an If Then Else statement to validate input data Microsoft Visual Basic 2005: Reloaded, Second Edition 44
45 Using Logical Operators in an If Then Else Statement (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 45
46 Using Logical Operators in an If Then Else Statement (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 46
47 Using Logical Operators in an If Then Else Statement (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 47
48 The String.IsNullOrEmpty Method String.IsNullOrEmpty method: determine if a control s Text property or String variable contains data Microsoft Visual Basic 2005: Reloaded, Second Edition 48
49 The String.IsNullOrEmpty Method (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 49
50 Modifying the Skate-Away Sales Application Microsoft Visual Basic 2005: Reloaded, Second Edition 50
51 Modifying the Skate-Away Sales Application (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 51
52 Modifying the Skate-Away Sales Application (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 52
53 Modifying the Skate-Away Sales Application (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 53
54 The MessageBox.Show Method MessageBox.Show method: Display message box with text, buttons and an icon When a message box is displayed, the program waits until the user selects a button MessageBox.Show returns an integer value indicating which button the user selected Microsoft Visual Basic 2005: Reloaded, Second Edition 54
55 The MessageBox.Show Method (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 55
56 The MessageBox.Show Method (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 56
57 The MessageBox.Show Method (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 57
58 The MessageBox.Show Method (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 58
59 The MessageBox.Show Method (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 59
60 The MessageBox.Show Method (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 60
61 Nested Selection Structures Nested selection structure: a selection structure that is completely contained within another selection structure Primary decision: decision made by the outer selection structure Secondary decision: decision made by the inner selection structure Microsoft Visual Basic 2005: Reloaded, Second Edition 61
62 Nested Selection Structures (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 62
63 Nested Selection Structures (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 63
64 Nested Selection Structures (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 64
65 Nested Selection Structures (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 65
66 Nested Selection Structures (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 66
67 Nested Selection Structures (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 67
68 Nested Selection Structures (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 68
69 The If/ElseIf/Else Selection Structure Need a procedure to display a message based on a letter grade: Letter grade A B C D F Message Excellent Above Average Average Below Average Below Average Microsoft Visual Basic 2005: Reloaded, Second Edition 69
70 The If/ElseIf/Else Selection Structure (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 70
71 The If/ElseIf/Else Selection Structure (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 71
72 The Case Selection Structure Case selection structure: Used when there are many paths from which to choose Simpler and clearer than using If/ElseIf/Else Microsoft Visual Basic 2005: Reloaded, Second Edition 72
73 The Case Selection Structure (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 73
74 The Case Selection Structure (continued) Case selection structure in a flowchart: Uses the diamond symbol One flowline into the diamond, but many flowlines out of the diamond Case selection structure evaluates an expression to determine which path to take Case selection structure: Begins with Select Case Ends with End Select Has one Case clause for each possible value Microsoft Visual Basic 2005: Reloaded, Second Edition 74
75 The Case Selection Structure (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 75
76 The Case Selection Structure (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 76
77 Using To and Is in an ExpressionList TO and IS keywords: specify a range of values in a Case clause s expression list TO: When you know both the upper and lower bounds of the range IS: When you know only one end of the range Used with a comparison operator Microsoft Visual Basic 2005: Reloaded, Second Edition 77
78 Using To and Is in an Expression List (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 78
79 Generating Random Integers Pseudo-random number generator: produces a sequence of numbers that meets certain statistical requirements for randomness Random.Next method: Generates a random integer Can specify a minimum and maximum value Microsoft Visual Basic 2005: Reloaded, Second Edition 79
80 Generating Random Integers (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 80
81 Generating Random Integers (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 81
82 Generating Random Integers (continued) Microsoft Visual Basic 2005: Reloaded, Second Edition 82
83 Programming Tutorial Microsoft Visual Basic 2005: Reloaded, Second Edition 83
84 Programming Example Microsoft Visual Basic 2005: Reloaded, Second Edition 84
85 Summary Selection structure is used for decisions Four forms of selection structures: If, If/Else, If/ElseIf/Else, and Case Diamond symbol represents a decision in a flowchart Expressions with comparison operators will result in an answer of True or False Variables declared within a selection expression have block-level scope Microsoft Visual Basic 2005: Reloaded, Second Edition 85
86 Summary (continued) Concatenation: linking two strings together Use logical operators to create compound conditions String.IsNullOrEmpty method will determine if a string contains data MessageBox.Show method returns an integer indicating which button was chosen Selection structures can be nested Microsoft Visual Basic 2005: Reloaded, Second Edition 86
87 Summary (continued) Use If/ElseIf/Else or Case structures when there are several possible alternative outcomes Use TO keyword to specify a range of valid values when both the lower and upper bound are known Use IS keyword with a comparison operator to specify a lower or upper bound but not both Use the pseudo-random number generator to generate random numbers Microsoft Visual Basic 2005: Reloaded, Second Edition 87
Skill Area 306: Develop and Implement Computer Program
Add your company slogan Skill Area 306: Develop and Implement Computer Program Computer Programming (YPG) LOGO Skill Area 306.2: Produce Structured Program 306.2.1 Write Algorithm 306.2.2 Apply appropriate
More informationMicrosoft Visual Basic 2012: Reloaded
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter Five More on the Selection Structure Objectives After studying this chapter, you should be able to: Determine whether a solution requires a nested
More informationMicrosoft Visual Basic 2015: Reloaded
Microsoft Visual Basic 2015: Reloaded Sixth Edition Chapter Five More on the Selection Structure Objectives After studying this chapter, you should be able to: Determine whether a solution requires a nested
More informationLecture 5 Tao Wang 1
Lecture 5 Tao Wang 1 Objectives In this chapter, you will learn about: Selection criteria Relational operators Logical operators The if-else statement Nested if statements C++ for Engineers and Scientists,
More informationChapter 4: Making Decisions
Chapter 4: Making Decisions 4.1 Relational Operators Relational Operators Used to compare numbers to determine relative order Operators: > Greater than < Less than >= Greater than or equal to
More informationChapter 4: Making Decisions
Chapter 4: Making Decisions CSE 142 - Computer Programming I 1 4.1 Relational Operators Relational Operators Used to compare numbers to determine relative order Operators: > Greater than < Less than >=
More informationChapter 4: Making Decisions. Copyright 2012 Pearson Education, Inc. Sunday, September 7, 14
Chapter 4: Making Decisions 4.1 Relational Operators Relational Operators Used to compare numbers to determine relative order Operators: > Greater than < Less than >= Greater than or equal to
More informationLECTURE 04 MAKING DECISIONS
PowerPoint Slides adapted from *Starting Out with C++: From Control Structures through Objects, 7/E* by *Tony Gaddis* Copyright 2012 Pearson Education Inc. COMPUTER PROGRAMMING LECTURE 04 MAKING DECISIONS
More informationProgramming Logic and Design Sixth Edition
Objectives Programming Logic and Design Sixth Edition Chapter 4 Making Decisions In this chapter, you will learn about: Evaluating Boolean expressions to make comparisons The relational comparison operators
More informationIntroduction 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 informationAn Introduction to Programming with C++ Sixth Edition. Chapter 7 The Repetition Structure
An Introduction to Programming with C++ Sixth Edition Chapter 7 The Repetition Structure Objectives Differentiate between a pretest loop and a posttest loop Include a pretest loop in pseudocode Include
More informationPLD Semester Exam Study Guide Dec. 2018
Covers material from Chapters 1-8. Semester Exam will be built from these questions and answers, though they will be re-ordered and re-numbered and possibly worded slightly differently than on this study
More informationChapter 4: Making Decisions
Chapter 4: Making Decisions Understanding Logic-Planning Tools and Pseudocode Decision Making A tool that helps programmers plan a program s logic by writing plain English statements Flowchart You write
More informationComputational Expression
Computational Expression Conditionals Janyl Jumadinova 10 October, 2018 Janyl Jumadinova Computational Expression 10 October, 2018 1 / 16 Computational Thinking: a problem solving process Decomposition
More informationMicrosoft 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 informationLoops! 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 informationIntroduction to Decision Structures. Boolean & If Statements. Different Types of Decisions. Boolean Logic. Relational Operators
Boolean & If Statements Introduction to Decision Structures Chapter 4 Fall 2015, CSUS Chapter 4.1 Introduction to Decision Structures Different Types of Decisions A decision structure allows a program
More informationIntroduction to Programming
Introduction to Programming session 6 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Spring 2011 These slides are created using Deitel s slides Sharif University of Technology Outlines
More informationStructured Program Development
Structured Program Development Chih-Wei Tang ( 唐之瑋 ) Department of Communication Engineering National Central University JhongLi, Taiwan Outline Introduction The selection statement if if.else switch The
More informationBIL101E: Introduction to Computers and Information systems Lecture 8
BIL101E: Introduction to Computers and Information systems Lecture 8 8.1 Algorithms 8.2 Pseudocode 8.3 Control Structures 8.4 Decision Making: Equality and Relational Operators 8.5 The if Selection Structure
More informationAn 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 informationDATABASE 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 informationChapter 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 informationUnit 3. Operators. School of Science and Technology INTRODUCTION
INTRODUCTION Operators Unit 3 In the previous units (unit 1 and 2) you have learned about the basics of computer programming, different data types, constants, keywords and basic structure of a C program.
More informationProgram Development. Chapter 3: Program Statements. Program Statements. Requirements. Java Software Solutions for AP* Computer Science A 2nd Edition
Chapter 3: Program Statements Presentation slides for Java Software Solutions for AP* Computer Science A 2nd Edition Program Development The creation of software involves four basic activities: establishing
More informationChapter 3: Program Statements
Chapter 3: Program Statements Presentation slides for Java Software Solutions for AP* Computer Science 3rd Edition by John Lewis, William Loftus, and Cara Cocking Java Software Solutions is published by
More informationSMS 3515: Scientific Computing. Sem /2015
s s SMS 3515: Scientific Computing Department of Computational and Theoretical Sciences, Kulliyyah of Science, International Islamic University Malaysia. Sem 1 2014/2015 The if s that are conceptually
More informationAn Introduction to Programming with C++ Sixth Edition. Chapter 8 More on the Repetition Structure
An Introduction to Programming with C++ Sixth Edition Chapter 8 More on the Repetition Structure Objectives Include a posttest loop in pseudocode Include a posttest loop in a flowchart Code a posttest
More informationCS 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 informationSelec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Fall 2016 Howard Rosenthal
Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Fall 2016 Howard Rosenthal Lesson Goals Understand Control Structures Understand how to control the flow of a program
More informationChapter 4 The If Then Statement
The If Then Statement Conditional control structure, also called a decision structure Executes a set of statements when a condition is true The condition is a Boolean expression For example, the statement
More informationSelec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Spring 2016 Howard Rosenthal
Selec%on and Decision Structures in Java: If Statements and Switch Statements CSC 121 Spring 2016 Howard Rosenthal Lesson Goals Understand Control Structures Understand how to control the flow of a program
More informationControl Structures. Lecture 4 COP 3014 Fall September 18, 2017
Control Structures Lecture 4 COP 3014 Fall 2017 September 18, 2017 Control Flow Control flow refers to the specification of the order in which the individual statements, instructions or function calls
More informationIntroduction to C Programming
1 2 Introduction to C Programming 2.6 Decision Making: Equality and Relational Operators 2 Executable statements Perform actions (calculations, input/output of data) Perform decisions - May want to print
More informationCT 229 Java Syntax Continued
CT 229 Java Syntax Continued 29/09/2006 CT229 Lab Assignments One Week Extension for Lab Assignment 1. Due Date: Oct 8 th Before submission make sure that the name of each.java file matches the name given
More informationChapter 4: Control structures. Repetition
Chapter 4: Control structures Repetition Loop Statements After reading and studying this Section, student should be able to Implement repetition control in a program using while statements. Implement repetition
More informationMicrosoft 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 informationObjectives. Chapter 4: Control Structures I (Selection) Objectives (cont d.) Control Structures. Control Structures (cont d.) Relational Operators
Objectives Chapter 4: Control Structures I (Selection) In this chapter, you will: Learn about control structures Examine relational and logical operators Explore how to form and evaluate logical (Boolean)
More informationLECTURE 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 informationIntroduction. C provides two styles of flow control:
Introduction C provides two styles of flow control: Branching Looping Branching is deciding what actions to take and looping is deciding how many times to take a certain action. Branching constructs: if
More informationThere are algorithms, however, that need to execute statements in some other kind of ordering depending on certain conditions.
Introduction In the programs that we have dealt with so far, all statements inside the main function were executed in sequence as they appeared, one after the other. This type of sequencing is adequate
More information4.1. Chapter 4: Simple Program Scheme. Simple Program Scheme. Relational Operators. So far our programs follow a simple scheme
Chapter 4: 4.1 Making Decisions Relational Operators Simple Program Scheme Simple Program Scheme So far our programs follow a simple scheme Gather input from the user Perform one or more calculations Display
More informationDecision Making in C
Decision Making in C Decision making structures require that the programmer specify one or more conditions to be evaluated or tested by the program, along with a statement or statements to be executed
More informationChapter 4: Control structures
Chapter 4: Control structures Repetition Loop Statements After reading and studying this Section, student should be able to Implement repetition control in a program using while statements. Implement repetition
More informationChapter 4: Control Structures I (Selection) Objectives. Objectives (cont d.) Control Structures. Control Structures (cont d.
Chapter 4: Control Structures I (Selection) In this chapter, you will: Objectives Learn about control structures Examine relational and logical operators Explore how to form and evaluate logical (Boolean)
More informationFRAC: Language Reference Manual
FRAC: Language Reference Manual Justin Chiang jc4127 Kunal Kamath kak2211 Calvin Li ctl2124 Anne Zhang az2350 1. Introduction FRAC is a domain-specific programming language that enables the programmer
More informationUsing Boolean Expressions. Multiway Branches. More about C++ Loop Statements. Designing Loops. In this chapter, you will learn about:
Chapter 3 In this chapter, you will learn about: Using Boolean Expressions Multiway Branches More about C++ Loop Statements Designing Loops Boolean Expressions Take the Value true or false Boolean Value
More informationCS 199 Computer Programming. Spring 2018 Lecture 5 Control Statements
CS 199 Computer Programming Spring 2018 Lecture 5 Control Statements Control Structures 3 control structures Sequence structure Programs executed sequentially by default Branch structure Unconditional
More informationTheory of control structures
Theory of control structures Paper written by Bohm and Jacopini in 1966 proposed that all programs can be written using 3 types of control structures. Theory of control structures sequential structures
More informationChapter 2. Flow of Control. Copyright 2016 Pearson, Inc. All rights reserved.
Chapter 2 Flow of Control Copyright 2016 Pearson, Inc. All rights reserved. Learning Objectives Boolean Expressions Building, Evaluating & Precedence Rules Branching Mechanisms if-else switch Nesting if-else
More informationComputers and FORTRAN Language Fortran 95/2003. Dr. Isaac Gang Tuesday March 1, 2011 Lecture 3 notes. Topics:
Computers and FORTRAN Language Fortran 95/2003 Dr. Isaac Gang Tuesday March 1, 2011 Lecture 3 notes Topics: - Program Design - Logical Operators - Logical Variables - Control Statements Any FORTRAN program
More informationARG! Language Reference Manual
ARG! Language Reference Manual Ryan Eagan, Mike Goldin, River Keefer, Shivangi Saxena 1. Introduction ARG is a language to be used to make programming a less frustrating experience. It is similar to C
More informationIndividual research task. You should all have completed the research task set last week. Please make sure you hand it in today.
Lecture 6 Individual research task. You should all have completed the research task set last week. Please make sure you hand it in today. Previously Decision structures with flowcharts Boolean logic UML
More informationRepetition 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 informationCondition-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 informationFlow of Control. Flow of control The order in which statements are executed. Transfer of control
1 Programming in C Flow of Control Flow of control The order in which statements are executed Transfer of control When the next statement executed is not the next one in sequence 2 Flow of Control Control
More informationV2 2/4/ Ch Programming in C. Flow of Control. Flow of Control. Flow of control The order in which statements are executed
Programming in C 1 Flow of Control Flow of control The order in which statements are executed Transfer of control When the next statement executed is not the next one in sequence 2 Flow of Control Control
More informationCHAPTER 2.1 CONTROL STRUCTURES (SELECTION) Dr. Shady Yehia Elmashad
CHAPTER 2.1 CONTROL STRUCTURES (SELECTION) Dr. Shady Yehia Elmashad Outline 1. The if Selection Structure 2. The if/else Selection Structure 3. The switch Multiple-Selection Structure 1. The if Selection
More informationSFPL Reference Manual
1 SFPL Reference Manual By: Huang-Hsu Chen (hc2237) Xiao Song Lu(xl2144) Natasha Nezhdanova(nin2001) Ling Zhu(lz2153) 2 1. Lexical Conventions 1.1 Tokens There are six classes of tokes: identifiers, keywords,
More informationLoops and Conditionals. HORT Lecture 11 Instructor: Kranthi Varala
Loops and Conditionals HORT 59000 Lecture 11 Instructor: Kranthi Varala Relational Operators These operators compare the value of two expressions and returns a Boolean value. Beware of comparing across
More informationCP FAQS Q-1) Define flowchart and explain Various symbols of flowchart Q-2) Explain basic structure of c language Documentation section :
CP FAQS Q-1) Define flowchart and explain Various symbols of flowchart ANS. Flowchart:- A diagrametic reperesentation of program is known as flowchart Symbols Q-2) Explain basic structure of c language
More informationConditionals and Loops
Conditionals and Loops Conditionals and Loops Now we will examine programming statements that allow us to: make decisions repeat processing steps in a loop Chapter 5 focuses on: boolean expressions conditional
More informationTest #2 October 8, 2015
CPSC 1040 Name: Test #2 October 8, 2015 Closed notes, closed laptop, calculators OK. Please use a pencil. 100 points, 5 point bonus. Maximum score 105. Weight of each section in parentheses. If you need
More informationLogical Operators and switch
Lecture 5 Relational and Equivalence Operators SYS-1S22 / MTH-1A66 Logical Operators and switch Stuart Gibson sg@sys.uea.ac.uk S01.09A 1 Relational Operator Meaning < Less than > Greater than
More informationCS110D: PROGRAMMING LANGUAGE I
CS110D: PROGRAMMING LANGUAGE I Computer Science department Lecture 5&6: Loops Lecture Contents Why loops?? While loops for loops do while loops Nested control structures Motivation Suppose that you need
More informationOverview 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 informationDecisions. Arizona State University 1
Decisions CSE100 Principles of Programming with C++, Fall 2018 (based off Chapter 4 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University
More informationLCSL Reference Manual
LCSL Reference Manual Sachin Nene, Chaue Shen, Bogdan Caprita, Julian Maller 1.1 Lexical Conventions 1.1.1 Comments Comments begin with (* and end with *) 1.1.2 Variables Variables consist solely of alphanumeric
More informationOverview: Programming Concepts. Programming Concepts. Names, Values, And Variables
Chapter 18: Get With the Program: Fundamental Concepts Expressed in JavaScript Fluency with Information Technology Third Edition by Lawrence Snyder Overview: Programming Concepts Programming: Act of formulating
More informationOverview: Programming Concepts. Programming Concepts. Chapter 18: Get With the Program: Fundamental Concepts Expressed in JavaScript
Chapter 18: Get With the Program: Fundamental Concepts Expressed in JavaScript Fluency with Information Technology Third Edition by Lawrence Snyder Overview: Programming Concepts Programming: Act of formulating
More informationProgram Development. Java Program Statements. Design. Requirements. Testing. Implementation
Program Development Java Program Statements Selim Aksoy Bilkent University Department of Computer Engineering saksoy@cs.bilkent.edu.tr The creation of software involves four basic activities: establishing
More informationIntroduction 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 informationChapter 4: Basic C Operators
Chapter 4: Basic C Operators In this chapter, you will learn about: Arithmetic operators Unary operators Binary operators Assignment operators Equalities and relational operators Logical operators Conditional
More informationSTUDENT OUTLINE. Lesson 8: Structured Programming, Control Structures, if-else Statements, Pseudocode
STUDENT OUTLINE Lesson 8: Structured Programming, Control Structures, if- Statements, Pseudocode INTRODUCTION: This lesson is the first of four covering the standard control structures of a high-level
More informationThe sequence of steps to be performed in order to solve a problem by the computer is known as an algorithm.
CHAPTER 1&2 OBJECTIVES After completing this chapter, you will be able to: Understand the basics and Advantages of an algorithm. Analysis various algorithms. Understand a flowchart. Steps involved in designing
More informationMore Things We Can Do With It! Overview. Circle Calculations. πr 2. π = More operators and expression types More statements
More Things We Can Do With It! More operators and expression types More s 11 October 2007 Ariel Shamir 1 Overview Variables and declaration More operators and expressions String type and getting input
More informationCOP 2000 Introduction to Computer Programming Mid-Term Exam Review
he exam format will be different from the online quizzes. It will be written on the test paper with questions similar to those shown on the following pages. he exam will be closed book, but students can
More informationChapter 2 Working with Data Types and Operators
JavaScript, Fourth Edition 2-1 Chapter 2 Working with Data Types and Operators At a Glance Instructor s Manual Table of Contents Overview Objectives Teaching Tips Quick Quizzes Class Discussion Topics
More informationC-LANGUAGE CURRICULAM
C-LANGUAGE CURRICULAM Duration: 2 Months. 1. Introducing C 1.1 History of C Origin Standardization C-Based Languages 1.2 Strengths and Weaknesses Of C Strengths Weaknesses Effective Use of C 2. C Fundamentals
More informationSTUDENT LESSON A12 Iterations
STUDENT LESSON A12 Iterations Java Curriculum for AP Computer Science, Student Lesson A12 1 STUDENT LESSON A12 Iterations INTRODUCTION: Solving problems on a computer very often requires a repetition of
More informationChapter 3 Structured Program Development
1 Chapter 3 Structured Program Development Copyright 2007 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 3 - Structured Program Development Outline 3.1 Introduction
More informationMicrosoft Visual Basic 2015: Reloaded
Microsoft Visual Basic 2015: Reloaded Sixth Edition Chapter Seven More on the Repetition Structure Objectives After studying this chapter, you should be able to: Code a counter-controlled loop Nest repetition
More informationIntroduction to Computer Programming CSCI-UA 2. Review Midterm Exam 1
Review Midterm Exam 1 Review Midterm Exam 1 Exam on Monday, October 7 Data Types and Variables = Data Types and Variables Basic Data Types Integers Floating Point Numbers Strings Data Types and Variables
More informationChapter 3. More Flow of Control. Copyright 2008 Pearson Addison-Wesley. All rights reserved.
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 informationSubquery: There are basically three types of subqueries are:
Subquery: It is also known as Nested query. Sub queries are queries nested inside other queries, marked off with parentheses, and sometimes referred to as "inner" queries within "outer" queries. Subquery
More informationControl Structures: if and while A C S L E C T U R E 4
Control Structures: if and while A C S - 1903 L E C T U R E 4 Control structures 3 constructs are essential building blocks for programs Sequences compound statement Decisions if, switch, conditional operator
More informationDecision Structures. Start. Do I have a test in morning? Study for test. Watch TV tonight. Stop
Decision Structures In the programs created thus far, Visual Basic reads and processes each of the procedure instructions in turn, one after the other. This is known as sequential processing or as the
More informationLooping. Arizona State University 1
Looping CSE100 Principles of Programming with C++, Fall 2018 (based off Chapter 5 slides by Pearson) Ryan Dougherty Arizona State University http://www.public.asu.edu/~redoughe/ Arizona State University
More informationLab 4: Decisions and Boolean Logic This lab accompanies Chapter 4 of Starting Out with Programming Logic & Design.
Starting Out with Programming Logic and Design 1 Lab 4: Decisions and Boolean Logic This lab accompanies Chapter 4 of Starting Out with Programming Logic & Design. Name: Lab 4.1 Logical Operators and Dual
More informationThe PCAT Programming Language Reference Manual
The PCAT Programming Language Reference Manual Andrew Tolmach and Jingke Li Dept. of Computer Science Portland State University September 27, 1995 (revised October 15, 2002) 1 Introduction The PCAT language
More informationDarrell Bethea May 25, 2011
Darrell Bethea May 25, 2011 Yesterdays slides updated Midterm on tomorrow in SN014 Closed books, no notes, no computer Program 3 due Tuesday 2 3 A whirlwind tour of almost everything we have covered so
More informationLogical Operators and if/else statement. If Statement. If/Else (4.3)
Logical Operators and if/ statement 1 If Statement We may want to execute some code if an expression is true, and execute some other code when the expression is false. This can be done with two if statements
More information5. Control Statements
5. Control Statements This section of the course will introduce you to the major control statements in C++. These control statements are used to specify the branching in an algorithm/recipe. Control statements
More informationPetros: 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 informationEuclid s algorithm, 133
Index A Algorithm computer instructions, 4 data and variables, 5 develop algorithm, 6 American Standard Code for Information Interchange (ASCII) codes, 141 definition, 142 features, 142 Arithmetic expressions
More informationLoops and Files. Chapter 04 MIT 12043, Fundamentals of Programming By: S. Sabraz Nawaz
Loops and Files Chapter 04 MIT 12043, Fundamentals of Programming By: S. Sabraz Nawaz Chapter Topics o The Increment and Decrement Operators o The while Loop o Shorthand Assignment Operators o The do-while
More informationProgramming 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\n is used in a string to indicate the newline character. An expression produces data. The simplest expression
Chapter 1 Summary Comments are indicated by a hash sign # (also known as the pound or number sign). Text to the right of the hash sign is ignored. (But, hash loses its special meaning if it is part of
More informationThe SPL Programming Language Reference Manual
The SPL Programming Language Reference Manual Leonidas Fegaras University of Texas at Arlington Arlington, TX 76019 fegaras@cse.uta.edu February 27, 2018 1 Introduction The SPL language is a Small Programming
More information