Selection Structures: If and Switch Statements
|
|
- Briana Russell
- 7 years ago
- Views:
Transcription
1 Selection Structures: If and Switch Statements Chuan-Ming Liu Computer Science & Information Engineering National Taipei University of Technology Taiwan 1
2 Outline Control Structures Conditions The If Statement If Statements with Compound Statements Decision Steps in Algorithms More Problem Solving Nested If Statements and Multiple Alternative Decisions The Switch Statement Common Programming Errors 2
3 Control Structures Control structure controls the execution flow of a program combine individual instructions into a single logical unit with one entry point and one exit point Three kinds of control structures to control execution flow: sequence selection repetition 3
4 Compound Statement Compound statement group of statements bracketed by { and } that are executed sequentially { } statement 1 ; statement 2 ; statement n ; Example a function body consists of a single compound statement. 4
5 Selection Control Structure Selection control structure a control structure that chooses among alternative program statements 5
6 Outline Control Structures Conditions The If Statement If Statements with Compound Statements Decision Steps in Algorithms More Problem Solving Nested If Statements and Multiple Alternative Decisions The Switch Statement Common Programming Errors 6
7 Conditions A program chooses among alternative statements by testing the value of key variables. rest_heart_rate > 75 Condition an expression that is either false (represented by 0) or true (usually represented by 1) 7
8 Relational and Equality Operators Most conditions that we use to perform comparisons will have one of these forms: variable relational-operator variable variable relational-operator constant variable equality-operator variable variable equality-operator constant 8
9 Table Relational and Equality Operators 9
10 Sample Conditions 10
11 Logical Operators Logical expression an expression that uses one or more of the logical operators && (and), (or),! (not) Examples: salary < MIN_SALARY dependents > 5 temperature > 90.0 && humidity > 0.90 n >= 0 && n <= <= n && n <=
12 Logical Complement Logical complement (negation) the complement of a condition has the value 1 (true) when the condition s value is 0 (false); the complement of a condition has the value 0 (false) when the condition s value is nonzero (true)!(0 <= n && n <= 100) C accepts any nonzero value as a representation of true. 12
13 The && Operator (and) 13
14 The Operator (or) 14
15 The! Operator (not) 15
16 Operator Precedence (1) Unary operator an operator that has one operand The precedence of operators + and - depends on whether they have one operand or two. -x - y * z the unary minus is evaluated first (-x), then *, and then the second -. Use parentheses to change the order of operator evaluation. (x < y x < z) && x >
17 Operator Precedence (2) 17
18 Example Operator Precedence 18
19 Evaluation Tree 19
20 Short-Circuit Evaluation An expression of the form a b must be true if a is true. C stops evaluating the expression when it determines that the value of!flag is 1 (true). An expression of the form a && b must be false if a is false. short-circuit evaluation stopping evaluation of a logical expression as soon as its value can be determined 20
21 Range for min <= x && x <= max 21
22 Writing English Conditions in C assuming x is 3.0, y is 4.0, and z is 2.0 for the English condition x and y are greater than z. You may be tempted to write this as x && y > z /* invalid logical expression */ 22
23 Figure 4.3 Range for z > x x > y 23
24 Comparing Characters the digit characters and letters are ordered as expected (that is, '0'<'1'<'2'<... <'8'<'9' and 'a'<'b'<'c'... <'y'<'z'). 24
25 Logical Assignment (1) Use assignment statements to set such variables to true (a nonzero value) or false (0). Example int age; /* input - a person's age */ char gender; /* input - a person's gender */ int senior_citizen; /* logical - indicates senior status */ senior_citizen = (age >= 65); /* Set senior status */!senior_citizen senior_citizen && gender == 'M' 25
26 Logical Assignment (2) Example in_range = (n > -10 && n < 10); is_letter = ('A' <= ch && ch <= 'Z') ('a' <= ch && ch <= 'z'); Example even = (n % 2 == 0); 26
27 Complementing a Condition item == SENT!(item == SENT) item!= SENT The relational operator <= should be changed to >, < should be changed to >=, and so on. Use the! operator with more complicated expressions. status == 'S' && age > 25!(status == 'S' && age > 25) 27
28 DeMorgan s Theorem The complement of expr1 && expr2 is written as comp1 comp2, where comp1 is the complement of expr1, and comp2 is the complement of expr2. The complement of expr1 expr2 is written as comp1 && comp2, where comp1 is the complement of expr1, and comp2 is the complement of expr2. age > 25 && (status == 'S' status == 'D') age <= 25 (status!= 'S' && status!= 'D') 28
29 Outline Control Structures Conditions The If Statement If Statements with Compound Statements Decision Steps in Algorithms More Problem Solving Nested If Statements and Multiple Alternative Decisions The Switch Statement Common Programming Errors 29
30 The if Statement In C, the if statement is the primary selection control structure Consider if (rest_heart_rate > 56) printf("keep up your exercise program!\n"); else printf("your heart is in excellent health!\n"); The above statement select one of the two calls to printf according to the value of rest_hear_rate 30
31 Flowchart Flowchart a diagram that show the step-bystep execution of a control structure (a) Two Alternatives and (b) One Alternative 31
32 if Statement Syntax (1) 32
33 if Statement Syntax (2) /* Multiply Product by a nonzero X */ if (x!= 0.0) product = product * x; 33
34 Errors for the if statements Missing parentheses if crsr_or_frgt == 'C' printf("cruiser\n"); printf("combat ship\n"); improper placement of ; if (crsr_or_frgt == 'C'); printf("cruiser\n"); printf("combat ship\n"); 34
35 Program Style Format of the if Statement Indenting statement T and statement F to improve program readability. 35
36 Outline Control Structures Conditions The If Statement If Statements with Compound Statements Decision Steps in Algorithms More Problem Solving Nested If Statements and Multiple Alternative Decisions The Switch Statement Common Programming Errors 36
37 Compound Statements A compound statements consists of more than one statements in a block {}. One can have more than one statements following the condition or the keyword else. When the symbol { follows the condition or the keyword else, the C compiler either executes or skips all statements through the matching }. 37
38 if Statements with Compound Statements Example: computes the population growth from yesterday to today as a percentage of yesterday s population. if (pop_today > pop_yesterday) { growth = pop_today - pop_yesterday; growth_pct = * growth / pop_yesterday; printf("the growth percentage is %.2f\n", growth_pct); } 38
39 Compound Statements Example: if (ctri <= MAX_SAFE_CTRI) { printf("car #%d: safe\n", auto_id); safe = safe + 1; } else { } printf("car #%d: unsafe\n", auto_id); unsafe = unsafe + 1; If you omit the braces enclosing the compound statements, the if statement would end after the first printf call. The compiler would mark the keyword else as an error. 39
40 Program Style The placement of the braces is a matter of personal preference. The form shown in the previous example. if (condition) { true task } else { false task } 40
41 Tracing an if Statement (1) Hand trace (desk check) step-by-step simulation of an algorithm s execution For special situations, what would happen if x were equal to y? 41
42 Tracing an if Statement (2) 42
43 Outline Control Structures Conditions The If Statement If Statements with Compound Statements Decision Steps in Algorithms More Problem Solving Nested If Statements and Multiple Alternative Decisions The Switch Statement Common Programming Errors 43
44 Decision Steps in Algorithms Algorithm steps that select from a choice of actions are called decision steps CASE STUDY Water Bill Problem computes a customer s water bill $35 water demand charge $1.10 for every thousand gallons used $2 late charge 44
45 ANALYSIS and DATA REQUIREMENTS (1) Problem Constants DEMAND_CHG /* basic water demand charge */ PER_1000_CHG 1.10 /* charge per thousand gallons used */ LATE_CHG 2.00 /* surcharge on an unpaid balance */ Problem Inputs int previous /* meter reading from previous quarter in thousands of gallons */ int current /* meter reading from current quarter */ double unpaid /* unpaid balance of previous bill */ 45
46 ANALYSIS and DATA REQUIREMENTS (2) Problem Outputs double bill /* water bill */ double use_charge /* charge for actual water use */ double late_charge /* charge for nonpayment of part Relevant Formulas of previous balance */ water bill = demand charge + use charge + unpaid balance + applicable late charge 46
47 DESIGN and INITIAL ALGORITHM 1. Display user instructions. 2. Get data: unpaid balance, previous and current meter readings. 3. Compute use charge. 4. Determine applicable late charge. 5. Figure bill amount. 6. Display the bill amount and charges. 47
48 Structure Chart 48
49 Function: comp_use_charge Data requirements for comp_use_charge Input Parameters int previous /* meter reading from previous quarter in thousands of gallons */ int current /* meter reading from current quarter */ Return Value double use_charge /* charge for actual water use */ Program Variable int used /* thousands of gallons used this quarter */ Relevant Formulas used = current meter reading. previous meter reading use charge = used charge per thousand gallons 49
50 Algorithm for comp_use_charge Algorithm: 1. used = current - previous 2. use_charge = used * PER_1000_CHG 50
51 Function: comp_late_charge Data requirements for comp_late_charge Input Parameter double unpaid /* unpaid balance of previous bill */ Return Value double late_charge /* charge for nonpayment of part of previous balance */ 51
52 Algorithm for comp_late_charge Algorithm if unpaid > 0 else assess late charge assess no late charge pseudocode a combination of English phrases and C constructs to describe algorithm steps 52
53 Function: display_bill Data requirement for display_bill Input Parameters double late_charge /* charge for nonpayment of part of previous balance */ double bill /* bill amount */ double unpaid /* unpaid balance Algorithm for display_bill 1. if late_charge > 0 display late charge and unpaid balance 2. Display the bill amount. 53
54 IMPLEMENTATION To write each function subprogram, declare all identifiers listed in the function data requirements as either formal parameters or local variables, depending on how the identifier is used by the function. After you write each function heading, copy it into the function prototype area preceding function main. 54
55 Program for Water Bill Problem 55
56 56
57 57
58 58
59 Execution Example 59
60 Program Style Cohesive Functions Cohesive function a function that performs a single operation Writing cohesive functions is good programming style, because cohesive functions are easier to read, write, debug, and maintain, and are more likely to be reusable. 60
61 Program Style Using Constant Macros Use of constant macro names rather than actual values has two advantages. First, the original statements are easier to understand because they use the descriptive names rather than numbers. Second, a program written using constant macros is much easier to maintain than one written with constant values. 61
62 Outline Control Structures Conditions The If Statement If Statements with Compound Statements Decision Steps in Algorithms More Problem Solving Nested If Statements and Multiple Alternative Decisions The Switch Statement Common Programming Errors 62
63 Data Flow Information Data flow information is an important part of system documentation because it shows what program variables are processed by each step and the manner in which those variables are processed 63
64 Modifying a Program with Function Subprograms Often what appears to be a new problem will turn out to be a variation of one that you have already solved. An important skill in problem solving is the ability to recognize that one problem is similar to another solved earlier. If the original program is well designed and modular, the programmer will be able to accommodate changing specifications with a minimum of effort. 64
65 CASE STUDY CASE STUDY Water Bill with Conservation Requirements Use no more than 95 percent of the amount of water the customer used in the same quarter last year. Otherwise, they will be charged for all their water use at twice the rate. 65
66 Additional Data Requirements ADDITIONS TO DATA REQUIREMENTS Problem Constants OVERUSE_CHG_RATE 2.0 /* double use charge as nonconservation penalty */ CONSERV_RATE 95 /* percent of last year's use allowed this year */ Problem Inputs int use_last_year /* use for same quarter last year */ 66
67 Algorithm for comp_use_charge Algorithm: 1. used = current - previous 2. if guidelines are met use_charge is used * PER_1000_CHARGE else notify customer of overuse use_charge = used * overuse_chg_rate * PER_1000_CHG 67
68 Revised comp_use_charge 68
69 Outline Control Structures Conditions The If Statement If Statements with Compound Statements Decision Steps in Algorithms More Problem Solving Nested If Statements and Multiple Alternative Decisions The Switch Statement Common Programming Errors 69
70 Nested if Statements (1) nested if statement an if statement with another if statement as its true task or its false task 70
71 Nested if Statements (2) 71
72 Nested if v.s. Sequence of ifs Example: if (x > 0) num_pos = num_pos + 1; if (x < 0) num_neg = num_neg + 1; if (x == 0) num_zero = num_zero + 1; Sequence of these if statements may be logically equivalent but is neither as readable nor as efficient. The sequence does not clearly show that exactly one is executed. It is less efficient because all three of the conditions are always tested. 72
73 Multiple-Alternative Decision In situations in which each false task is followed by an if-then-else statement, you can code the nested if as the multiple-alternative decision. 73
74 Multiple-Alternative Decision Syntax (1) 74
75 Multiple-Alternative Decision Syntax (2) 75
76 Order of Conditions The order of the conditions can affect the outcome Example: noise loudness measurement if (noise_db <= 50) printf("%d-decibel noise is quiet.\n", noise_db); else if (noise_db <= 70) printf("%d-decibel noise is intrusive.\n", noise_db); else if (noise_db <= 90) printf("%d-decibel noise is annoying.\n", noise_db); else if (noise_db <= 110) printf("%d-decibel noise is very annoying.\n", noise_db); else printf("%d-decibel noise is uncomfortable.\n", noise_db); 76
77 Incorrect Perception of Noise Loudness if (noise_db <= 110) printf("%d-decibel noise is very annoying.\n", noise_db); else if (noise_db <= 90) printf("%d-decibel noise is annoying.\n", noise_db); else if (noise_db <= 70) printf("%d-decibel noise is intrusive.\n", noise_db); else if (noise_db <= 50) printf("%d-decibel noise is quiet.\n", noise_db); else printf("%d-decibel noise is uncomfortable.\n",noise_db); 77
78 Decision Table for Tax 78
79 Function comp_tax (1) 79
80 Function comp_tax (2) 80
81 Nested if Statements More Than One Variable 81
82 Flowchart of Road Sign Decision Process 82
83 Road Sign Decision Process 83
84 Associating else with if (1) C associates an else with the most recent incomplete if. 84
85 Associating else with if (2) 85
86 Associating else with if (3) To force the else to be the false branch of the first if, we place braces around the true task of this first decision. 86
87 Outline Control Structures Conditions The If Statement If Statements with Compound Statements Decision Steps in Algorithms More Problem Solving Nested If Statements and Multiple Alternative Decisions The Switch Statement Common Programming Errors 87
88 The switch Statement The switch statement is especially useful when the selection is based on the value of a single variable or of a simple expression (called the controlling expression). The value of this expression may be of type int or char, but not of type double. 88
89 Example Type char Case 89
90 More on switch Statement (1) The value of the variable class expression is evaluated; then, the list of case labels is searched until one label that matches. Statements following the matching case label are executed until a break statement is encountered. If no case label matches the value of the switch statement s controlling expression, the statements following the default label are executed, if there is a default label. 90
91 More on switch Statement (2) It is important to remember that type int and char values may be used as case labels, but strings and type double values cannot be used. Another common error is the omission of the break statement at the end of one alternative. In such a situation, execution falls through into the next alternative. 91
92 switch Statement Syntax (1) 92
93 switch Statement Syntax (2) 93
94 switch Statement Syntax (3) 94
95 Nested if v.s. switch The switch is more readable Case labels that contain type double values or strings are not permitted. You should include a default label in switch statements wherever possible. 95
96 Outline Control Structures Conditions The If Statement If Statements with Compound Statements Decision Steps in Algorithms More Problem Solving Nested If Statements and Multiple Alternative Decisions The Switch Statement Common Programming Errors 96
97 Common Programming Errors (1) The following if statement displays Condition is true for all values of x. if (0 <= x <= 4) printf("condition is true\n"); In order to check if x is in the range 0 to 4, you should use the condition (0 <= x && x <= 4) The code fragment that follows always prints x is 10, regardless of the value of x. if (x = 10) printf("x is 10"); 97
98 Common Programming Errors (2) In a compound statement, if the braces are missing, only the first statement will be considered part of the task. if (x > 0) sum = sum + x; printf("greater than zero\n"); else printf("less than or equal to zero\n"); In multiple-alternative format, the logic should be constructed so each intermediate condition falls on the false branch of the previous decision. 98
Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.
Name: Class: Date: Exam #1 - Prep True/False Indicate whether the statement is true or false. 1. Programming is the process of writing a computer program in a language that the computer can respond to
More informationOutline. Conditional Statements. Logical Data in C. Logical Expressions. Relational Examples. Relational Operators
Conditional Statements For computer to make decisions, must be able to test CONDITIONS IF it is raining THEN I will not go outside IF Count is not zero THEN the Average is Sum divided by Count Conditions
More informationChapter One Introduction to Programming
Chapter One Introduction to Programming 1-1 Algorithm and Flowchart Algorithm is a step-by-step procedure for calculation. More precisely, algorithm is an effective method expressed as a finite list of
More information9 Control Statements. 9.1 Introduction. 9.2 Objectives. 9.3 Statements
9 Control Statements 9.1 Introduction The normal flow of execution in a high level language is sequential, i.e., each statement is executed in the order of its appearance in the program. However, depending
More informationSources: On the Web: Slides will be available on:
C programming Introduction The basics of algorithms Structure of a C code, compilation step Constant, variable type, variable scope Expression and operators: assignment, arithmetic operators, comparison,
More informationAlgorithm & Flowchart & Pseudo code. Staff Incharge: S.Sasirekha
Algorithm & Flowchart & Pseudo code Staff Incharge: S.Sasirekha Computer Programming and Languages Computers work on a set of instructions called computer program, which clearly specify the ways to carry
More informationSelection Statements
Chapter 5 Selection Statements 1 Statements So far, we ve used return statements and expression ess statements. e ts. Most of C s remaining statements fall into three categories: Selection statements:
More informationTwo-way selection. Branching and Looping
Control Structures: are those statements that decide the order in which individual statements or instructions of a program are executed or evaluated. Control Structures are broadly classified into: 1.
More informationEmbedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C
Embedded Systems A Review of ANSI C and Considerations for Embedded C Programming Dr. Jeff Jackson Lecture 2-1 Review of ANSI C Topics Basic features of C C fundamentals Basic data types Expressions Selection
More informationKeywords are identifiers having predefined meanings in C programming language. The list of keywords used in standard C are : unsigned void
1. Explain C tokens Tokens are basic building blocks of a C program. A token is the smallest element of a C program that is meaningful to the compiler. The C compiler recognizes the following kinds of
More informationChapter 2: Algorithm Discovery and Design. Invitation to Computer Science, C++ Version, Third Edition
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science, C++ Version, Third Edition Objectives In this chapter, you will learn about: Representing algorithms Examples of algorithmic problem
More informationRepetition Using the End of File Condition
Repetition Using the End of File Condition Quick Start Compile step once always g++ -o Scan4 Scan4.cpp mkdir labs cd labs Execute step mkdir 4 Scan4 cd 4 cp /samples/csc/155/labs/4/*. Submit step emacs
More informationJavaScript: Control Statements I
1 7 JavaScript: Control Statements I 7.1 Introduction 2 The techniques you will learn here are applicable to most high-level languages, including JavaScript 1 7.2 Algorithms 3 Any computable problem can
More informationChapter 5. Selection 5-1
Chapter 5 Selection 5-1 Selection (Decision) The second control logic structure is selection: Selection Choosing between two or more alternative actions. Selection statements alter the sequential flow
More informationIntroduction to Java Applications. 2005 Pearson Education, Inc. All rights reserved.
1 2 Introduction to Java Applications 2.2 First Program in Java: Printing a Line of Text 2 Application Executes when you use the java command to launch the Java Virtual Machine (JVM) Sample program Displays
More informationCS 241 Data Organization Coding Standards
CS 241 Data Organization Coding Standards Brooke Chenoweth University of New Mexico Spring 2016 CS-241 Coding Standards All projects and labs must follow the great and hallowed CS-241 coding standards.
More informationALGORITHMS AND FLOWCHARTS. By Miss Reham Tufail
ALGORITHMS AND FLOWCHARTS By Miss Reham Tufail ALGORITHMS AND FLOWCHARTS A typical programming task can be divided into two phases: Problem solving phase produce an ordered sequence of steps that describe
More informationCOMPUTER SCIENCE (5651) Test at a Glance
COMPUTER SCIENCE (5651) Test at a Glance Test Name Computer Science Test Code 5651 Time Number of Questions Test Delivery 3 hours 100 selected-response questions Computer delivered Content Categories Approximate
More informationChapter 13: Program Development and Programming Languages
Understanding Computers Today and Tomorrow 12 th Edition Chapter 13: Program Development and Programming Languages Learning Objectives Understand the differences between structured programming, object-oriented
More informationMULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.
Exam Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question. 1) The JDK command to compile a class in the file Test.java is A) java Test.java B) java
More informationGeneral Software Development Standards and Guidelines Version 3.5
NATIONAL WEATHER SERVICE OFFICE of HYDROLOGIC DEVELOPMENT Science Infusion Software Engineering Process Group (SISEPG) General Software Development Standards and Guidelines 7/30/2007 Revision History Date
More informationAn Introduction to the WEB Style of Literate Programming
An Introduction to the WEB Style of Literate Programming Literate Programming by Bart Childs One of the greatest needs in computing is the reduction of the cost of maintenance of codes. Maintenance programmers
More informationConditions & Boolean Expressions
Conditions & Boolean Expressions 1 In C++, in order to ask a question, a program makes an assertion which is evaluated to either true (nonzero) or false (zero) by the computer at run time. Example: In
More informationPROG0101 Fundamentals of Programming PROG0101 FUNDAMENTALS OF PROGRAMMING. Chapter 3 Algorithms
PROG0101 FUNDAMENTALS OF PROGRAMMING Chapter 3 1 Introduction to A sequence of instructions. A procedure or formula for solving a problem. It was created mathematician, Mohammed ibn-musa al-khwarizmi.
More informationFlowchart Techniques
C H A P T E R 1 Flowchart Techniques 1.1 Programming Aids Programmers use different kinds of tools or aids which help them in developing programs faster and better. Such aids are studied in the following
More informationModeling, Computers, and Error Analysis Mathematical Modeling and Engineering Problem-Solving
Next: Roots of Equations Up: Numerical Analysis for Chemical Previous: Contents Subsections Mathematical Modeling and Engineering Problem-Solving A Simple Mathematical Model Computers and Software The
More informationStatements and Control Flow
Contents 1. Introduction 2. Types and Variables 3. Statements and Control Flow 4. Reading Input 5. Classes and Objects 6. Arrays 7. Methods 8. Scope and Lifetime 9. Utility classes 10. Introduction to
More information2 SYSTEM DESCRIPTION TECHNIQUES
2 SYSTEM DESCRIPTION TECHNIQUES 2.1 INTRODUCTION Graphical representation of any process is always better and more meaningful than its representation in words. Moreover, it is very difficult to arrange
More informationSection 1.5 Exponents, Square Roots, and the Order of Operations
Section 1.5 Exponents, Square Roots, and the Order of Operations Objectives In this section, you will learn to: To successfully complete this section, you need to understand: Identify perfect squares.
More informationChapter 8 Selection 8-1
Chapter 8 Selection 8-1 Selection (Decision) The second control logic structure is selection: Selection Choosing between two or more alternative actions. Selection statements alter the sequential flow
More informationPL / SQL Basics. Chapter 3
PL / SQL Basics Chapter 3 PL / SQL Basics PL / SQL block Lexical units Variable declarations PL / SQL types Expressions and operators PL / SQL control structures PL / SQL style guide 2 PL / SQL Block Basic
More informationCOMP 110 Prasun Dewan 1
COMP 110 Prasun Dewan 1 12. Conditionals Real-life algorithms seldom do the same thing each time they are executed. For instance, our plan for studying this chapter may be to read it in the park, if it
More information13 Classes & Objects with Constructors/Destructors
13 Classes & Objects with Constructors/Destructors 13.1 Introduction In object oriented programming, the emphasis is on data rather than function. Class is a way that binds the data & function together.
More informationNotes on Algorithms, Pseudocode, and Flowcharts
Notes on Algorithms, Pseudocode, and Flowcharts Introduction Do you like hot sauce? Here is an algorithm for how to make a good one: Volcanic Hot Sauce (from: http://recipeland.com/recipe/v/volcanic-hot-sauce-1125)
More informationKITES TECHNOLOGY COURSE MODULE (C, C++, DS)
KITES TECHNOLOGY 360 Degree Solution www.kitestechnology.com/academy.php info@kitestechnology.com technologykites@gmail.com Contact: - 8961334776 9433759247 9830639522.NET JAVA WEB DESIGN PHP SQL, PL/SQL
More informationWESTMORELAND COUNTY PUBLIC SCHOOLS 2011 2012 Integrated Instructional Pacing Guide and Checklist Computer Math
Textbook Correlation WESTMORELAND COUNTY PUBLIC SCHOOLS 2011 2012 Integrated Instructional Pacing Guide and Checklist Computer Math Following Directions Unit FIRST QUARTER AND SECOND QUARTER Logic Unit
More informationLecture 2 Notes: Flow of Control
6.096 Introduction to C++ January, 2011 Massachusetts Institute of Technology John Marrero Lecture 2 Notes: Flow of Control 1 Motivation Normally, a program executes statements from first to last. The
More informationFundamentals of Programming and Software Development Lesson Objectives
Lesson Unit 1: INTRODUCTION TO COMPUTERS Computer History Create a timeline illustrating the most significant contributions to computing technology Describe the history and evolution of the computer Identify
More informationLecture 9. Semantic Analysis Scoping and Symbol Table
Lecture 9. Semantic Analysis Scoping and Symbol Table Wei Le 2015.10 Outline Semantic analysis Scoping The Role of Symbol Table Implementing a Symbol Table Semantic Analysis Parser builds abstract syntax
More information6. Control Structures
- 35 - Control Structures: 6. Control Structures A program is usually not limited to a linear sequence of instructions. During its process it may bifurcate, repeat code or take decisions. For that purpose,
More informationChapter 14: Boolean Expressions Bradley Kjell (Revised 10/08/08)
Chapter 14: Boolean Expressions Bradley Kjell (Revised 10/08/08) The if statements of the previous chapters ask simple questions such as count
More informationDebugging. Common Semantic Errors ESE112. Java Library. It is highly unlikely that you will write code that will work on the first go
Debugging ESE112 Java Programming: API, Psuedo-Code, Scope It is highly unlikely that you will write code that will work on the first go Bugs or errors Syntax Fixable if you learn to read compiler error
More informationChapter 12 Programming Concepts and Languages
Chapter 12 Programming Concepts and Languages Chapter 12 Programming Concepts and Languages Paradigm Publishing, Inc. 12-1 Presentation Overview Programming Concepts Problem-Solving Techniques The Evolution
More informationConditional Statements. 15-110 Summer 2010 Margaret Reid-Miller
Conditional Statements 15-110 Summer 2010 Margaret Reid-Miller Conditional statements Within a method, we can alter the flow of control (the order in which statements are executed) using either conditionals
More informationCOWLEY COLLEGE & Area Vocational Technical School
COWLEY COLLEGE & Area Vocational Technical School COURSE PROCEDURE FOR COBOL PROGRAMMING CIS1866 3 Credit Hours Student Level: This course is open to students on the college level in either Freshman or
More informationInformatica e Sistemi in Tempo Reale
Informatica e Sistemi in Tempo Reale Introduction to C programming Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 25, 2010 G. Lipari (Scuola Superiore Sant Anna)
More informationCourse Title: Software Development
Course Title: Software Development Unit: Customer Service Content Standard(s) and Depth of 1. Analyze customer software needs and system requirements to design an information technology-based project plan.
More informationMoving from CS 61A Scheme to CS 61B Java
Moving from CS 61A Scheme to CS 61B Java Introduction Java is an object-oriented language. This document describes some of the differences between object-oriented programming in Scheme (which we hope you
More informationJavaScript: Introduction to Scripting. 2008 Pearson Education, Inc. All rights reserved.
1 6 JavaScript: Introduction to Scripting 2 Comment is free, but facts are sacred. C. P. Scott The creditor hath a better memory than the debtor. James Howell When faced with a decision, I always ask,
More informationMATLAB Programming. Problem 1: Sequential
Division of Engineering Fundamentals, Copyright 1999 by J.C. Malzahn Kampe 1 / 21 MATLAB Programming When we use the phrase computer solution, it should be understood that a computer will only follow directions;
More informationPerl in a nutshell. First CGI Script and Perl. Creating a Link to a Script. print Function. Parsing Data 4/27/2009. First CGI Script and Perl
First CGI Script and Perl Perl in a nutshell Prof. Rasley shebang line tells the operating system where the Perl interpreter is located necessary on UNIX comment line ignored by the Perl interpreter End
More informationAlgorithms, Flowcharts & Program Design. ComPro
Algorithms, Flowcharts & Program Design ComPro Definition Algorithm: o sequence of steps to be performed in order to solve a problem by the computer. Flowchart: o graphical or symbolic representation of
More informationChapter 13: Program Development and Programming Languages
15 th Edition Understanding Computers Today and Tomorrow Comprehensive Chapter 13: Program Development and Programming Languages Deborah Morley Charles S. Parker Copyright 2015 Cengage Learning Learning
More informationEl Dorado Union High School District Educational Services
El Dorado Union High School District Course of Study Information Page Course Title: ACE Computer Programming I (#494) Rationale: A continuum of courses, including advanced classes in technology is needed.
More informationWriting Control Structures
Writing Control Structures Copyright 2006, Oracle. All rights reserved. Oracle Database 10g: PL/SQL Fundamentals 5-1 Objectives After completing this lesson, you should be able to do the following: Identify
More informationI PUC - Computer Science. Practical s Syllabus. Contents
I PUC - Computer Science Practical s Syllabus Contents Topics 1 Overview Of a Computer 1.1 Introduction 1.2 Functional Components of a computer (Working of each unit) 1.3 Evolution Of Computers 1.4 Generations
More informationHigh-Level Programming Languages. Nell Dale & John Lewis (adaptation by Michael Goldwasser)
High-Level Programming Languages Nell Dale & John Lewis (adaptation by Michael Goldwasser) Low-Level Languages What are disadvantages of low-level languages? (e.g., machine code or assembly code) Programming
More informationPython Programming: An Introduction To Computer Science
Python Programming: An Introduction To Computer Science Chapter 8 Booleans and Control Structures Python Programming, 2/e 1 Objectives æ To understand the concept of Boolean expressions and the bool data
More informationSoftware Engineering Techniques
Software Engineering Techniques Low level design issues for programming-in-the-large. Software Quality Design by contract Pre- and post conditions Class invariants Ten do Ten do nots Another type of summary
More informationALGORITHMS AND FLOWCHARTS
ALGORITHMS AND FLOWCHARTS A typical programming task can be divided into two phases: Problem solving phase produce an ordered sequence of steps that describe solution of problem this sequence of steps
More informationGlossary of Object Oriented Terms
Appendix E Glossary of Object Oriented Terms abstract class: A class primarily intended to define an instance, but can not be instantiated without additional methods. abstract data type: An abstraction
More informationProblem Solving Basics and Computer Programming
Problem Solving Basics and Computer Programming A programming language independent companion to Roberge/Bauer/Smith, "Engaged Learning for Programming in C++: A Laboratory Course", Jones and Bartlett Publishers,
More informationGrade descriptions Computer Science Stage 1
Stage 1 A B C Accurately uses a wide range of terms and concepts associated with current personal computers, home networking and internet connections. Correctly uses non-technical and a range of technical
More informationVisual Logic Instructions and Assignments
Visual Logic Instructions and Assignments Visual Logic can be installed from the CD that accompanies our textbook. It is a nifty tool for creating program flowcharts, but that is only half of the story.
More informationSo far we have considered only numeric processing, i.e. processing of numeric data represented
Chapter 4 Processing Character Data So far we have considered only numeric processing, i.e. processing of numeric data represented as integer and oating point types. Humans also use computers to manipulate
More informationUnix Shell Scripts. Contents. 1 Introduction. Norman Matloff. July 30, 2008. 1 Introduction 1. 2 Invoking Shell Scripts 2
Unix Shell Scripts Norman Matloff July 30, 2008 Contents 1 Introduction 1 2 Invoking Shell Scripts 2 2.1 Direct Interpretation....................................... 2 2.2 Indirect Interpretation......................................
More informationThe design recipe. Programs as communication. Some goals for software design. Readings: HtDP, sections 1-5
The design recipe Readings: HtDP, sections 1-5 (ordering of topics is different in lectures, different examples will be used) Survival and Style Guides CS 135 Winter 2016 02: The design recipe 1 Programs
More informationPROBLEM SOLVING SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON
PROBLEM SOLVING WITH SEVENTH EDITION WALTER SAVITCH UNIVERSITY OF CALIFORNIA, SAN DIEGO CONTRIBUTOR KENRICK MOCK UNIVERSITY OF ALASKA, ANCHORAGE PEARSON Addison Wesley Boston San Francisco New York London
More informationVISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0
VISUAL GUIDE to RX Scripting for Roulette Xtreme - System Designer 2.0 UX Software - 2009 TABLE OF CONTENTS INTRODUCTION... ii What is this book about?... iii How to use this book... iii Time to start...
More informationThe Elective Part of the NSS ICT Curriculum D. Software Development
of the NSS ICT Curriculum D. Software Development Mr. CHEUNG Wah-sang / Mr. WONG Wing-hong, Robert Member of CDC HKEAA Committee on ICT (Senior Secondary) 1 D. Software Development The concepts / skills
More informationCS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013
Oct 4, 2013, p 1 Name: CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013 1. (max 18) 4. (max 16) 2. (max 12) 5. (max 12) 3. (max 24) 6. (max 18) Total: (max 100)
More informationPART-A Questions. 2. How does an enumerated statement differ from a typedef statement?
1. Distinguish & and && operators. PART-A Questions 2. How does an enumerated statement differ from a typedef statement? 3. What are the various members of a class? 4. Who can access the protected members
More informationProgramming and Software Development (PSD)
Programming and Software Development (PSD) Course Descriptions Fundamentals of Information Systems Technology This course is a survey of computer technologies. This course may include computer history,
More informationWhat is a Loop? Pretest Loops in C++ Types of Loop Testing. Count-controlled loops. Loops can be...
What is a Loop? CSC Intermediate Programming Looping A loop is a repetition control structure It causes a single statement or a group of statements to be executed repeatedly It uses a condition to control
More informationQUIZ-II QUIZ-II. Chapter 5: Control Structures II (Repetition) Objectives. Objectives (cont d.) 20/11/2015. EEE 117 Computer Programming Fall-2015 1
QUIZ-II Write a program that mimics a calculator. The program should take as input two integers and the operation to be performed. It should then output the numbers, the operator, and the result. (For
More informationLecture 1 Introduction to Java
Programming Languages: Java Lecture 1 Introduction to Java Instructor: Omer Boyaci 1 2 Course Information History of Java Introduction First Program in Java: Printing a Line of Text Modifying Our First
More informationPROGRAMMING IN C PROGRAMMING IN C CONTENT AT A GLANCE
PROGRAMMING IN C CONTENT AT A GLANCE 1 MODULE 1 Unit 1 : Basics of Programming Unit 2 : Fundamentals Unit 3 : C Operators MODULE 2 unit 1 : Input Output Statements unit 2 : Control Structures unit 3 :
More informationAutomata and Computability. Solutions to Exercises
Automata and Computability Solutions to Exercises Fall 25 Alexis Maciel Department of Computer Science Clarkson University Copyright c 25 Alexis Maciel ii Contents Preface vii Introduction 2 Finite Automata
More informationProgramming Logic and Design Eighth Edi(on
Programming Logic and Design Eighth Edi(on Chapter 3 Understanding Structure Objec3ves In this chapter, you will learn about: The disadvantages of unstructured spaghea code The three basic structures sequence,
More informationThe programming language C. sws1 1
The programming language C sws1 1 The programming language C invented by Dennis Ritchie in early 1970s who used it to write the first Hello World program C was used to write UNIX Standardised as K&C (Kernighan
More informationKeil C51 Cross Compiler
Keil C51 Cross Compiler ANSI C Compiler Generates fast compact code for the 8051 and it s derivatives Advantages of C over Assembler Do not need to know the microcontroller instruction set Register allocation
More informationIntroduction to Python
Caltech/LEAD Summer 2012 Computer Science Lecture 2: July 10, 2012 Introduction to Python The Python shell Outline Python as a calculator Arithmetic expressions Operator precedence Variables and assignment
More informationTotal Quality Management (TQM) Quality, Success and Failure. Total Quality Management (TQM) vs. Process Reengineering (BPR)
Total Quality Management (TQM) Quality, Success and Failure Total Quality Management (TQM) is a concept that makes quality control a responsibility to be shared by all people in an organization. M7011
More informationTutorial on C Language Programming
Tutorial on C Language Programming Teodor Rus rus@cs.uiowa.edu The University of Iowa, Department of Computer Science Introduction to System Software p.1/64 Tutorial on C programming C program structure:
More informationComputer Programming I
Computer Programming I COP 2210 Syllabus Spring Semester 2012 Instructor: Greg Shaw Office: ECS 313 (Engineering and Computer Science Bldg) Office Hours: Tuesday: 2:50 4:50, 7:45 8:30 Thursday: 2:50 4:50,
More informationMultiplying Fractions
. Multiplying Fractions. OBJECTIVES 1. Multiply two fractions. Multiply two mixed numbers. Simplify before multiplying fractions 4. Estimate products by rounding Multiplication is the easiest of the four
More informationComputer Programming Lecturer: Dr. Laith Abdullah Mohammed
Algorithm: A step-by-step procedure for solving a problem in a finite amount of time. Algorithms can be represented using Flow Charts. CHARACTERISTICS OF AN ALGORITHM: Computer Programming Lecturer: Dr.
More informationGreatest Common Factor and Least Common Multiple
Greatest Common Factor and Least Common Multiple Intro In order to understand the concepts of Greatest Common Factor (GCF) and Least Common Multiple (LCM), we need to define two key terms: Multiple: Multiples
More informationSemantic Analysis: Types and Type Checking
Semantic Analysis Semantic Analysis: Types and Type Checking CS 471 October 10, 2007 Source code Lexical Analysis tokens Syntactic Analysis AST Semantic Analysis AST Intermediate Code Gen lexical errors
More informationReverse Literate Programming
Reverse Literate Programming Markus Knasmüller Johannes Kepler University Linz Altenbergerstraße 39 Linz, 4040, Austria Tel. +43 732 2468 7133 Fax +43 732 2468 7138 Internet knasmueller@ssw.uni-linz.ac.at
More informationSpecimen 2015 am/pm Time allowed: 1hr 30mins
SPECIMEN MATERIAL GCSE COMPUTER SCIENCE 8520/1 Paper 1 Specimen 2015 am/pm Time allowed: 1hr 30mins Materials There are no additional materials required for this paper. Instructions Use black ink or black
More informationHow To Port A Program To Dynamic C (C) (C-Based) (Program) (For A Non Portable Program) (Un Portable) (Permanent) (Non Portable) C-Based (Programs) (Powerpoint)
TN203 Porting a Program to Dynamic C Introduction Dynamic C has a number of improvements and differences compared to many other C compiler systems. This application note gives instructions and suggestions
More informationComputer Programming I & II*
Computer Programming I & II* Career Cluster Information Technology Course Code 10152 Prerequisite(s) Computer Applications, Introduction to Information Technology Careers (recommended), Computer Hardware
More informationPROGRAMMABLE LOGIC CONTROLLERS Unit code: A/601/1625 QCF level: 4 Credit value: 15 OUTCOME 3 PART 1
UNIT 22: PROGRAMMABLE LOGIC CONTROLLERS Unit code: A/601/1625 QCF level: 4 Credit value: 15 OUTCOME 3 PART 1 This work covers part of outcome 3 of the Edexcel standard module: Outcome 3 is the most demanding
More informationEMC Publishing. Ontario Curriculum Computer and Information Science Grade 11
EMC Publishing Ontario Curriculum Computer and Information Science Grade 11 Correlations for: An Introduction to Programming Using Microsoft Visual Basic 2005 Theory and Foundation Overall Expectations
More informationInstructor Özgür ZEYDAN (PhD) CIV 112 Computer Programming http://cevre.beun.edu.tr/zeydan/
Algorithms Pseudocode Flowcharts (PhD) CIV 112 Computer Programming http://cevre.beun.edu.tr/zeydan/ Why do we have to learn computer programming? Computers can make calculations at a blazing speed without
More informationProgramming and Software Development CTAG Alignments
Programming and Software Development CTAG Alignments This document contains information about four Career-Technical Articulation Numbers (CTANs) for Programming and Software Development Career-Technical
More informationJava Application Developer Certificate Program Competencies
Java Application Developer Certificate Program Competencies After completing the following units, you will be able to: Basic Programming Logic Explain the steps involved in the program development cycle
More information