4.8 Thedo while Repetition Statement Thedo while repetition statement

Size: px
Start display at page:

Download "4.8 Thedo while Repetition Statement Thedo while repetition statement"

Transcription

1 1 4.8 hedo while Repetition Statement hedo while repetition statement Similar to thewhile structure Condition for repetition tested after the body of the loop is performed All actions are performed at least once ormat: do { statement statement; } while ( condition ); condition false true 2 hedo while Repetition Example Example (lettingcounter = 1): do { printf( "%d ", counter ); } while (++counter <= 10); Prints the integers from1to10 1

2 fig04_09.c 3 1 /* ig. 4.9: fig04_09.c 2 Using the do/while repetition statement */ 3 #include <stdio.h> 4 5 /* function main begins program execution */ 6 int main() 7 { 8 int counter = 1; /* initialize counter */ 9 10 do { 11 printf( "%d ", counter ); /* display counter */ 12 } while ( ++counter <= 10 ); /* end do...while */ return 0; /* indicate program ended successfully */ } /* end function main */ Program Output hebreak andcontinue Statements break Causes immediate exit from awhile,for, do while or switch statement Program execution continues with the first statement after the structure Common uses of thebreak statement Escape early from a loop Skip the remainder of aswitch statement 2

3 1 /* ig. 4.11: fig04_11.c 2 Using the break statement in a for statement */ 3 #include <stdio.h> 4 5 /* function main begins program execution */ 6 int main() 7 { 8 int x; /* counter */ 9 10 /* loop 10 times */ 11 for ( x = 1; x <= 10; x++ ) { /* if x is 5, terminate loop */ 14 if ( x == 5 ) { 15 break; /* break loop only if x is 5 */ 16 } /* end if */ printf( "%d ", x ); /* display value of x */ 19 } /* end for */ printf( "\nbroke out of loop at x == %d\n", x ); return 0; /* indicate program ended successfully */ } /* end function main */ Broke out of loop at x == 5 fig04_11.c Program Output 5 6 continue hecontinue Statement Skips the remaining statements in the body of a while,for ordo while statement Proceeds with the next iteration of the loop while anddo while Loop-continuation test is evaluated immediately after thecontinue statement is executed for Increment expression is executed, then the loopcontinuation test is evaluated 3

4 1 /* ig. 4.12: fig04_12.c 2 Using the continue statement in a for statement */ 3 #include <stdio.h> 4 5 /* function main begins program execution */ 6 int main() 7 { 8 int x; /* counter */ 9 10 /* loop 10 times */ 11 for ( x = 1; x <= 10; x++ ) { /* if x is 5, continue with next iteration of loop */ 14 if ( x == 5 ) { 15 continue; /* skip remaining code in loop body */ 16 } /* end if */ printf( "%d ", x ); /* display value of x */ 19 } /* end for */ printf( "\nused continue to skip printing the value 5\n" ); return 0; /* indicate program ended successfully */ } /* end function main */ Used continue to skip printing the value 5 fig04_12.c Program Output 7 練 習 一 寫 一 個 C 語 言 程 式, 讓 使 用 者 輸 入 一 個 介 於 1 至 100 間 的 整 數 N 輸 出 1 至 N 間 ( 含 N) 所 有 不 為 3 或 5 倍 數 的 數 字 並 輸 出 這 樣 的 數 字 有 多 少 個 提 示 : 使 用 一 個 for 或 while 迴 圈 檢 查 1 至 N 間 的 所 有 整 數, 並 配 合 使 用 continue 敘 述 8 執 行 範 例 Input a number between 1 and 100: 16 1, 2, 4, 7, 8, 11, 13, 14, 16. otal 9 numbers. 4

5 4.10 Logical Operators 9 && ( logical AND ) Returnstrue if both conditions aretrue ( logical OR ) Returnstrue if either of its conditions aretrue! ( logical NO, logical negation ) Reverses the truth/falsity of its condition Unary operator, has one operand Useful as conditions in loops Expression true && false true false!false Result false true true he ruth able of && 10 expression1 expression2 expression1 && expression nonzero 0 nonzero 0 0 nonzero nonzero 1 5

6 he ruth able of 11 expression1 expression2 expression1 expression nonzero 1 nonzero 0 1 nonzero nonzero 1 he ruth able of! 12 expression! Expression 0 1 nonzero 0 6

7 Logical Operators Operators Associativity ype ! (type) right to left unary * / % left to right multiplicative + - left to right additive < <= > >= left to right relational ==!= left to right equality && left to right logical AND left to right logical OR?: right to left conditional = += -= *= /= %= right to left assignment, left to right comma 4.11 Confusing Equality (==) and Assignment (=) Operators Dangerous error Does not ordinarily cause syntax errors Any expression that produces a value can be used in control structures Nonzero values aretrue, zero values are false Example using==: if ( paycode == 4 ) printf( "You get a bonus!\n" ); 14 CheckspayCode, if it is4then a bonus is awarded 7

8 4.11 Confusing Equality (==) and Assignment (=) Operators Example, replacing== with=: 15 if ( paycode = 4 ) printf( "You get a bonus!\n" ); his setspaycode to4 4 is nonzero, so expression istrue, and bonus awarded no matter what thepaycode was Logic error, not a syntax error 16 lvalues L-values Expressions that can appear on the left side of an equation heir values can be changed, such as variable names x = 4; 8

9 17 rvalues R-values Expressions that can appear on the right side of an equation Constants, such as numbers Cannot write4 = x; Must writex = 4; lvalues can be used as rvalues, but not vice versa y = x; Structured-Programming Summary Se q u e n c e Sequence structure. 9

10 4.12 Structured-Programming Summary 19 Selection structure statement if statement (single selection) if else statement (double selection). switch (multiple selection) break break break 4.12 Structured-Programming Summary 20 Repetition structure while statement do while statement for statement 10

11 Structured Programming Structured programming Only single-entry/single-exit control structures are used Easier than unstructured programs to understand, test, debug and, modify programs 22 Rules for Structured Programming developed by programming community Rules: 1.Begin with the simplest flowchart 2.Stacking rule: Any rectangle (action) can be replaced by two rectangles (actions) in sequence 3.Nesting rule: Any rectangle (action) can be replaced by any control structure (sequence,if, if else,switch,while,do while or for) 4.Rules 2 and 3 can be applied in any order and multiple times 11

12 4.12 Structured-Programming Summary 23 Rule 1 - Begin with the simplest flowchart Rule 2 - Any rectangle can be replaced by two rectangles in sequence Rule 2 Rule 2 Rule Structured-Programming Summary 24 Rule 3 - Replace any rectangle with a control structure Rule 3 Rule 3 Rule 3 12

13 4.12 Structured-Programming Summary 25 Stacke d b uilding b lo cks Nested build ing blocks Overla pping b uilding blocks (Illega l in structured pro gra ms) 4.12 Structured-Programming Summary 26 igure 4.23 An unstructured flowchart. 13

14 Structured-Programming Summary All programs can be broken down into three controls Sequence handled automatically by compiler Selection if,if else orswitch Repetition while,do while orfor Can only be combined in two ways Nesting (rule 3) Stacking (rule 2) Any selection can be rewritten as anif statement, and any repetition can be rewritten as awhile statement 14

Keywords are identifiers having predefined meanings in C programming language. The list of keywords used in standard C are : unsigned void

Keywords 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 information

Informatica e Sistemi in Tempo Reale

Informatica 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 information

Lecture 2 Notes: Flow of Control

Lecture 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 information

6. Control Structures

6. 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 information

QUIZ-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 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 information

IS0020 Program Design and Software Tools Midterm, Feb 24, 2004. Instruction

IS0020 Program Design and Software Tools Midterm, Feb 24, 2004. Instruction IS0020 Program Design and Software Tools Midterm, Feb 24, 2004 Name: Instruction There are two parts in this test. The first part contains 50 questions worth 80 points. The second part constitutes 20 points

More information

Selection Statements

Selection 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 information

Embedded Systems. Review of ANSI C Topics. A Review of ANSI C and Considerations for Embedded C Programming. Basic features of C

Embedded 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 information

9 Control Statements. 9.1 Introduction. 9.2 Objectives. 9.3 Statements

9 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 information

JavaScript: Control Statements I

JavaScript: 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 information

Algorithm & Flowchart & Pseudo code. Staff Incharge: S.Sasirekha

Algorithm & 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 information

Two-way selection. Branching and Looping

Two-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 information

What is a Loop? Pretest Loops in C++ Types of Loop Testing. Count-controlled loops. Loops can be...

What 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 information

Sources: On the Web: Slides will be available on:

Sources: 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 information

Fundamentals of Programming

Fundamentals of Programming Fundamentals of Programming Introduction to the C language Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa February 29, 2012 G. Lipari (Scuola Superiore Sant Anna) The C language

More information

Boolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority)

Boolean Expressions, Conditions, Loops, and Enumerations. Precedence Rules (from highest to lowest priority) Boolean Expressions, Conditions, Loops, and Enumerations Relational Operators == // true if two values are equivalent!= // true if two values are not equivalent < // true if left value is less than the

More information

Chapter One Introduction to Programming

Chapter 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 information

ESCI 386 IDL Programming for Advanced Earth Science Applications Lesson 6 Program Control

ESCI 386 IDL Programming for Advanced Earth Science Applications Lesson 6 Program Control ESCI 386 IDL Programming for Advanced Earth Science Applications Lesson 6 Program Control Reading: Bowman, Chapters 16 CODE BLOCKS A code block consists of several lines of code contained between a BEGIN

More information

ALGORITHMS AND FLOWCHARTS

ALGORITHMS 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 information

Object Oriented Software Design

Object Oriented Software Design Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa September 14, 2011 G. Lipari (Scuola Superiore Sant Anna) Introduction

More information

Lecture 1 Introduction to Java

Lecture 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 information

5.2 Q2 The control variable of a counter-controlled loop should be declared as: a.int. b.float. c.double. d.any of the above. ANS: a. int.

5.2 Q2 The control variable of a counter-controlled loop should be declared as: a.int. b.float. c.double. d.any of the above. ANS: a. int. Java How to Program, 5/e Test Item File 1 of 5 Chapter 5 Section 5.2 5.2 Q1 Counter-controlled repetition requires a.a control variable and initial value. b.a control variable increment (or decrement).

More information

Market Access To Taiwan. By Jane Peng TÜV Rheinland Taiwan Ltd.

Market Access To Taiwan. By Jane Peng TÜV Rheinland Taiwan Ltd. Market Access To Taiwan By Jane Peng TÜV Rheinland Taiwan Ltd. Content General Introduction Taiwan BSMI mark Products, Scope and approval scheme News Update TÜV Rheinland s One-Stop Services Contact info.

More information

CS 241 Data Organization Coding Standards

CS 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 information

In this Chapter you ll learn:

In this Chapter you ll learn: Now go, write it before them in a table, and note it in a book. Isaiah 30:8 To go beyond is as wrong as to fall short. Confucius Begin at the beginning, and go on till you come to the end: then stop. Lewis

More information

Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language

Translating to Java. Translation. Input. Many Level Translations. read, get, input, ask, request. Requirements Design Algorithm Java Machine Language Translation Translating to Java Introduction to Computer Programming The job of a programmer is to translate a problem description into a computer language. You need to be able to convert a problem description

More information

CS 141: Introduction to (Java) Programming: Exam 1 Jenny Orr Willamette University Fall 2013

CS 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 information

Chapter 8 Selection 8-1

Chapter 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 information

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

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 information

Outline. Conditional Statements. Logical Data in C. Logical Expressions. Relational Examples. Relational Operators

Outline. 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 information

PROGRAMMING IN C PROGRAMMING IN C CONTENT AT A GLANCE

PROGRAMMING 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 information

LC Paper No. PWSC269/15-16(01)

LC Paper No. PWSC269/15-16(01) Legislative Council Public Works Subcommittee meeting on 11 June 2016 118KA Renovation works for the West Wing of the former Central Government Offices for office use by the Department of Justice and law-related

More information

JAVA - QUICK GUIDE. Java SE is freely available from the link Download Java. So you download a version based on your operating system.

JAVA - QUICK GUIDE. Java SE is freely available from the link Download Java. So you download a version based on your operating system. http://www.tutorialspoint.com/java/java_quick_guide.htm JAVA - QUICK GUIDE Copyright tutorialspoint.com What is Java? Java is: Object Oriented Platform independent: Simple Secure Architectural- neutral

More information

Flowchart Techniques

Flowchart 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 information

EFL Business Writing with Task-based Learning Approach: A Case Study of Student Strategies to Overcome Difficulties

EFL Business Writing with Task-based Learning Approach: A Case Study of Student Strategies to Overcome Difficulties 2013 年 12 月 ISSN 1815-0373 第 十 卷 第 二 期 P217-238 EFL Business Writing with Task-based Learning Approach: A Case Study of Student Strategies to Overcome Difficulties Shu-Chiao Tsai Associate professor, Department

More information

Object Oriented Software Design

Object Oriented Software Design Object Oriented Software Design Introduction to Java - II Giuseppe Lipari http://retis.sssup.it/~lipari Scuola Superiore Sant Anna Pisa October 28, 2010 G. Lipari (Scuola Superiore Sant Anna) Introduction

More information

MATLAB Programming. Problem 1: Sequential

MATLAB 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 information

Boolean Expressions & the if Statement

Boolean Expressions & the if Statement Midterm Results Boolean Expressions & the if Statement September 24, 2007 Average: 91.6 Median: 94 Standard Deviation: 18.80 Maximum: 129 (out of 130) ComS 207: Programming I (in Java) Iowa State University,

More information

While and Do-While Loops. 15-110 Summer 2010 Margaret Reid-Miller

While and Do-While Loops. 15-110 Summer 2010 Margaret Reid-Miller While and Do-While Loops 15-110 Margaret Reid-Miller Loops Within a method, we can alter the flow of control using either conditionals or loops. The loop statements while, do-while, and for allow us execute

More information

BASH Scripting. A bash script may consist of nothing but a series of command lines, e.g. The following helloworld.sh script simply does an echo.

BASH Scripting. A bash script may consist of nothing but a series of command lines, e.g. The following helloworld.sh script simply does an echo. BASH Scripting bash is great for simple scripts that automate things you would otherwise by typing on the command line. Your command line skills will carry over to bash scripting and vice versa. bash comments

More information

Introduction to Java

Introduction to Java Introduction to Java The HelloWorld program Primitive data types Assignment and arithmetic operations User input Conditional statements Looping Arrays CSA0011 Matthew Xuereb 2008 1 Java Overview A high

More information

Installation Guide 2-Port HD Cable KVM Switch with Audio GCS62HU PART NO. M1130

Installation Guide 2-Port HD Cable KVM Switch with Audio GCS62HU PART NO. M1130 Installation Guide 2-Port HD Cable KVM Switch with Audio GCS62HU PART NO. M1130 Table of Contents Package Contents 4 System Requirements 5 Overview 6 Standard Installation 7 Advanced Installation 9 LED

More information

ALGORITHMS AND FLOWCHARTS. By Miss Reham Tufail

ALGORITHMS 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 information

Statements and Control Flow

Statements 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 information

Pseudo code Tutorial and Exercises Teacher s Version

Pseudo code Tutorial and Exercises Teacher s Version Pseudo code Tutorial and Exercises Teacher s Version Pseudo-code is an informal way to express the design of a computer program or an algorithm in 1.45. The aim is to get the idea quickly and also easy

More information

J a v a Quiz (Unit 3, Test 0 Practice)

J a v a Quiz (Unit 3, Test 0 Practice) Computer Science S-111a: Intensive Introduction to Computer Science Using Java Handout #11 Your Name Teaching Fellow J a v a Quiz (Unit 3, Test 0 Practice) Multiple-choice questions are worth 2 points

More information

C++FA 5.1 PRACTICE MID-TERM EXAM

C++FA 5.1 PRACTICE MID-TERM EXAM C++FA 5.1 PRACTICE MID-TERM EXAM This practicemid-term exam covers sections C++FA 1.1 through C++FA 1.4 of C++ with Financial Applications by Ben Van Vliet, available at www.benvanvliet.net. 1.) A pointer

More information

Introduction to Java Applications. 2005 Pearson Education, Inc. All rights reserved.

Introduction 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 information

Boolean Expressions 1. In C++, the number 0 (zero) is considered to be false, all other numbers are true.

Boolean Expressions 1. In C++, the number 0 (zero) is considered to be false, all other numbers are true. Boolean Expressions Boolean Expressions Sometimes a programmer would like one statement, or group of statements to execute only if certain conditions are true. There may be a different statement, or group

More information

Visual Logic Instructions and Assignments

Visual 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 information

Moving from CS 61A Scheme to CS 61B Java

Moving 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 information

MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answers the question.

MULTIPLE 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 information

TIP: To access the WinRunner help system at any time, press the F1 key.

TIP: To access the WinRunner help system at any time, press the F1 key. CHAPTER 11 TEST SCRIPT LANGUAGE We will now look at the TSL language. You have already been exposed to this language at various points of this book. All the recorded scripts that WinRunner creates when

More information

Writing Control Structures

Writing 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 information

Instructor Özgür ZEYDAN (PhD) CIV 112 Computer Programming http://cevre.beun.edu.tr/zeydan/

Instructor Ö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 information

Perl 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

Perl 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 information

Chemistry I -- Final Exam

Chemistry I -- Final Exam Chemistry I -- Final Exam 01/1/13 Periodic Table of Elements Constants R = 8.314 J / mol K 1 atm = 760 Torr = 1.01x10 5 Pa = 0.081 L atm / K mol c =.9910 8 m/s = 8.314 L kpa / K mol h = 6.6310-34 Js Mass

More information

So far we have considered only numeric processing, i.e. processing of numeric data represented

So 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 information

2.3 WINDOW-TO-VIEWPORT COORDINATE TRANSFORMATION

2.3 WINDOW-TO-VIEWPORT COORDINATE TRANSFORMATION 2.3 WINDOW-TO-VIEWPORT COORDINATE TRANSFORMATION A world-coordinate area selected for display is called a window. An area on a display device to which a window is mapped is called a viewport. The window

More information

Chapter 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 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 information

1 Introduction. 2 Overview of the Tool. Program Visualization Tool for Educational Code Analysis

1 Introduction. 2 Overview of the Tool. Program Visualization Tool for Educational Code Analysis Program Visualization Tool for Educational Code Analysis Natalie Beams University of Oklahoma, Norman, OK nataliebeams@gmail.com Program Visualization Tool for Educational Code Analysis 1 Introduction

More information

REGULATIONS FOR THE DEGREE OF BACHELOR OF ARTS IN ARCHITECTURAL STUDIES (BA[ArchStud])

REGULATIONS FOR THE DEGREE OF BACHELOR OF ARTS IN ARCHITECTURAL STUDIES (BA[ArchStud]) REGULATIONS FOR THE DEGREE OF BACHELOR OF ARTS IN ARCHITECTURAL STUDIES (BA[ArchStud]) These regulations and syllabuses apply to students admitted in the 2011-12 academic year and thereafter. (See also

More information

VB.NET Programming Fundamentals

VB.NET Programming Fundamentals Chapter 3 Objectives Programming Fundamentals In this chapter, you will: Learn about the programming language Write a module definition Use variables and data types Compute with Write decision-making statements

More information

PL / SQL Basics. Chapter 3

PL / 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 information

UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming

UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming UIL Computer Science for Dummies by Jake Warren and works from Mr. Fleming 1 2 Foreword First of all, this book isn t really for dummies. I wrote it for myself and other kids who are on the team. Everything

More information

1.3 Conditionals and Loops

1.3 Conditionals and Loops A Foundation for Programming 1.3 Conditionals and Loops any program you might want to write objects functions and modules graphics, sound, and image I/O arrays conditionals and loops Math primitive data

More information

Programming MS Excel in Visual Basic (VBA)

Programming MS Excel in Visual Basic (VBA) Programming MS Excel in Visual Basic (VBA) Part 2-Branching & Looping, Message Boxes & Alerts by Kwabena Ofosu, Ph.D., P.E., PTOE Abstract This course is the second of a four-part series on computer programming

More information

Total 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) 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 information

促 進 市 場 競 爭 加 強 保 障 消 費 者

促 進 市 場 競 爭 加 強 保 障 消 費 者 通 訊 事 務 管 理 局 辦 公 室 2013 14 年 營 運 基 金 報 告 書 5 Facilitating Market Competition and Strengthening Consumer Protection 處 理 和 調 查 有 關 具 誤 導 性 或 欺 騙 性 行 為 的 電 訊 服 務 投 訴 2012 年 商 品 說 明 ( 不 良 營 商 手 法 )( 修 訂 )

More information

Case Study of a New Generation Call Center

Case Study of a New Generation Call Center Case Study of a New Generation Call Center Chiung-I Chang* and tzy-yau lee** *Department of Information Management National Taichung Institute of Technology E-mail: ccy@ntit.edu.tw **Department of Leisure

More information

PART-A Questions. 2. How does an enumerated statement differ from a typedef statement?

PART-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 information

UEE1302 (1102) F10 Introduction to Computers and Programming

UEE1302 (1102) F10 Introduction to Computers and Programming Computational Intelligence on Automation Lab @ NCTU UEE1302 (1102) F10 Introduction to Computers and Programming Programming Lecture 03 Flow of Control (Part II): Repetition while,for & do..while Learning

More information

Programming Logic and Design Eighth Edi(on

Programming 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 information

Conditionals (with solutions)

Conditionals (with solutions) Conditionals (with solutions) For exercises 1 to 27, indicate the output that will be produced. Assume the following declarations: final int MAX = 25, LIMIT = 100; int num1 = 12, num2 = 25, num3 = 87;

More information

The HKICPA Accounting and Business Management Case Competition 2015-16. Secondary School Group (Level 1)

The HKICPA Accounting and Business Management Case Competition 2015-16. Secondary School Group (Level 1) The HKICPA Accounting and Business Management Case Competition 2015-16 Secondary School Group (Level 1) The HKICPA Accounting and Business Management Case Competition 2015-16 Secondary School Group (Level

More information

arrays C Programming Language - Arrays

arrays C Programming Language - Arrays arrays So far, we have been using only scalar variables scalar meaning a variable with a single value But many things require a set of related values coordinates or vectors require 3 (or 2, or 4, or more)

More information

Stacks. Linear data structures

Stacks. Linear data structures Stacks Linear data structures Collection of components that can be arranged as a straight line Data structure grows or shrinks as we add or remove objects ADTs provide an abstract layer for various operations

More information

While Loop. 6. Iteration

While Loop. 6. Iteration While Loop 1 Loop - a control structure that causes a set of statements to be executed repeatedly, (reiterated). While statement - most versatile type of loop in C++ false while boolean expression true

More information

SHAU KEI WAN GOVERNMENT SECONDARY SCHOOL

SHAU KEI WAN GOVERNMENT SECONDARY SCHOOL 香 港 柴 灣 道 42 號 42 Chai Wan Road, Hong Kong Tel : (852) 2560 3544 Fax : (852) 2568 9708 URL : www.sgss.edu.hk Email : skwgss@edb.gov.hk 筲 箕 灣 官 立 中 學 SHAU KEI WAN GOVERNMENT SECONDARY SCHOOL --------------------------------------------------------------------------------------------------------------------------------

More information

The While Loop. Objectives. Textbook. WHILE Loops

The While Loop. Objectives. Textbook. WHILE Loops Objectives The While Loop 1E3 Topic 6 To recognise when a WHILE loop is needed. To be able to predict what a given WHILE loop will do. To be able to write a correct WHILE loop. To be able to use a WHILE

More information

An Introduction to Assembly Programming with the ARM 32-bit Processor Family

An Introduction to Assembly Programming with the ARM 32-bit Processor Family An Introduction to Assembly Programming with the ARM 32-bit Processor Family G. Agosta Politecnico di Milano December 3, 2011 Contents 1 Introduction 1 1.1 Prerequisites............................. 2

More information

C / C++ and Unix Programming. Materials adapted from Dan Hood and Dianna Xu

C / C++ and Unix Programming. Materials adapted from Dan Hood and Dianna Xu C / C++ and Unix Programming Materials adapted from Dan Hood and Dianna Xu 1 C and Unix Programming Today s goals ú History of C ú Basic types ú printf ú Arithmetic operations, types and casting ú Intro

More information

Chapter 3 Operators and Control Flow

Chapter 3 Operators and Control Flow Chapter 3 Operators and Control Flow I n this chapter, you will learn about operators, control flow statements, and the C# preprocessor. Operators provide syntax for performing different calculations or

More information

Keil C51 Cross Compiler

Keil 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 information

How to Write a Simple Makefile

How to Write a Simple Makefile Chapter 1 CHAPTER 1 How to Write a Simple Makefile The mechanics of programming usually follow a fairly simple routine of editing source files, compiling the source into an executable form, and debugging

More information

C Programming Tutorial

C Programming Tutorial C Programming Tutorial C PROGRAMMING TUTORIAL Simply Easy Learning by tutorialspoint.com tutorialspoint.com i C O P Y R I G H T & D I S C L A I M E R N O T I C E All the content and graphics on this tutorial

More information

PROG0101 Fundamentals of Programming PROG0101 FUNDAMENTALS OF PROGRAMMING. Chapter 3 Algorithms

PROG0101 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 information

The programming language C. sws1 1

The 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 information

LOOPS CHAPTER CHAPTER GOALS

LOOPS CHAPTER CHAPTER GOALS jfe_ch04_7.fm Page 139 Friday, May 8, 2009 2:45 PM LOOPS CHAPTER 4 CHAPTER GOALS To learn about while, for, and do loops To become familiar with common loop algorithms To understand nested loops To implement

More information

Command Scripts. 13.1 Running scripts: include and commands

Command Scripts. 13.1 Running scripts: include and commands 13 Command Scripts You will probably find that your most intensive use of AMPL s command environment occurs during the initial development of a model, when the results are unfamiliar and changes are frequent.

More information

CS106A, Stanford Handout #38. Strings and Chars

CS106A, Stanford Handout #38. Strings and Chars CS106A, Stanford Handout #38 Fall, 2004-05 Nick Parlante Strings and Chars The char type (pronounced "car") represents a single character. A char literal value can be written in the code using single quotes

More information

Machine Translation for Academic Purposes

Machine Translation for Academic Purposes Proceedings of the International Conference on TESOL and Translation 2009 December 2009: pp.133-148 Machine Translation for Academic Purposes Grace Hui-chin Lin PhD Texas A&M University College Station

More information

Phys4051: C Lecture 2 & 3. Comment Statements. C Data Types. Functions (Review) Comment Statements Variables & Operators Branching Instructions

Phys4051: C Lecture 2 & 3. Comment Statements. C Data Types. Functions (Review) Comment Statements Variables & Operators Branching Instructions Phys4051: C Lecture 2 & 3 Functions (Review) Comment Statements Variables & Operators Branching Instructions Comment Statements! Method 1: /* */! Method 2: // /* Single Line */ //Single Line /* This comment

More information

CS1010 Programming Methodology A beginning in problem solving in Computer Science. Aaron Tan http://www.comp.nus.edu.sg/~cs1010/ 20 July 2015

CS1010 Programming Methodology A beginning in problem solving in Computer Science. Aaron Tan http://www.comp.nus.edu.sg/~cs1010/ 20 July 2015 CS1010 Programming Methodology A beginning in problem solving in Computer Science Aaron Tan http://www.comp.nus.edu.sg/~cs1010/ 20 July 2015 Announcements This document is available on the CS1010 website

More information

Java Basics: Data Types, Variables, and Loops

Java Basics: Data Types, Variables, and Loops Java Basics: Data Types, Variables, and Loops If debugging is the process of removing software bugs, then programming must be the process of putting them in. - Edsger Dijkstra Plan for the Day Variables

More information

This loop prints out the numbers from 1 through 10 on separate lines. How does it work? Output: 1 2 3 4 5 6 7 8 9 10

This loop prints out the numbers from 1 through 10 on separate lines. How does it work? Output: 1 2 3 4 5 6 7 8 9 10 Java Loops & Methods The while loop Syntax: while ( condition is true ) { do these statements Just as it says, the statements execute while the condition is true. Once the condition becomes false, execution

More information

CompSci 125 Lecture 08. Chapter 5: Conditional Statements Chapter 4: return Statement

CompSci 125 Lecture 08. Chapter 5: Conditional Statements Chapter 4: return Statement CompSci 125 Lecture 08 Chapter 5: Conditional Statements Chapter 4: return Statement Homework Update HW3 Due 9/20 HW4 Due 9/27 Exam-1 10/2 Programming Assignment Update p1: Traffic Applet due Sept 21 (Submit

More information

Tutorial on C Language Programming

Tutorial 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 information