# Engineering Problem Solving with C++, Etter/Ingber

Size: px
Start display at page:

Transcription

1 Engineering Problem Solving with C++, Etter/Ingber Chapter 3 Control Structures 1

2 Control structures Algorithm Development Conditional Expressions Selection Statements Repetition Statements Structuring Input Loops 2

3 Structured Programming Evaluation of Alternative Solutions ALGORITHM DEVELOPMENT 3

4 Algorithm Development An algorithm is a sequence of steps for solving a problem. Engineering problem solutions to real world problems require complex algorithms. Development of a good algorithm increases the quality and maintainability of a solution, and reduces the overall time required to implement a correct solution. 4

5 Top-Down Design Top-down design begins with a "big picture" description of a problem solution in sequential steps. The sequential steps are refined until the steps are detailed enough to translate to language statements. The refined steps, or algorithm, can be described using pseudo code or flowcharts. 5

6 Evaluation of Alternative Solutions Most problems have more than one solution. There may not be a single best solution, but some solutions are better than others. Elements that contribute to a good solution: correctness reliability readability maintainability execution speed memory considerations user interface 6

7 Structured Programming A structured program is written using simple control structures, including: Sequence steps are performed one after another. Selection one set of statements is executed if a given condition is true, a different set of statements, or no statements at all, is executed if the condition is false. Repetition A set of statements is executed repeatedly as long as a given condition is true. 7

8 Structured Programming Sequence Selection false? true Repetition? true false? => conditional expression 8

9 Relational operators Logical operators CONDITIONAL EXPRESSIONS 9

10 Conditional Expressions A conditional expression is a Boolean expression that evaluates to true or false. Selection structures and repetition structures rely on conditional expressions. Relational operators and logical operators are used to form conditional expressions. 10

11 Relational Operators == equality!= non equality < less than > greater than <= less than equal to >= greater than equal to 11

12 Logical Operators! not && and or 12

13 Logical Operators A B A&&B A B!A!B Truth table for conditional expressions 0 = 13

14 Operator Precedence 1. < <= > >= 2. ==!= 3. && 4. 14

15 Practice! - evaluate 4 (-6<0)&&(12>=10) true && true results in true 4 (3.0 >= 2.0) (3.0 >= 4.0) true false results in true 4 (3.0 >= 2.0) && (3.0 >= 4.0) true && false results in false 15

16 if statement switch statement SELECTION STATEMENTS 16

17 Selection Statements The C++ programming language supports the implementation of selection with: if statements switch statements 17

18 The if statement if(expression) statement; /*single statement executed if expression is true */ // statement block is executed if expression is true. if(expression) { statement1; statement2; statement n; } 18

19 The if statement - examples if (x>0) ++k; if(x>0) { x=sqrt(x); ++k; } 19

20 The if - else statement if(expression) statement; else statement; if(expression) { statement block } else { statement block } 20

21 The nested if-else if(x > y) if(y < z) k++; else m++; else j++; 21

22 Practice! int x=9, y=7, z=2, k=0, m=0, j=0; if(x > y) if(y >z && y>k) k++; else m++; else j++; What are the values of j, k and m? 22

23 The switch statement switch(expression) { case constant: statement(s); break; case constant: statement(s); break; /* default is optional*/ default: statement(s); } 23

24 The switch statement Expression must be of type integer or character. The keyword case must be followed by a constant. break statement is required unless you want all subsequent statements to be executed. 24

25 switch statement example char ch; int ecount=0, vowels=0, other=0; cin.get(ch); while(!cin.eof()) { switch(ch) { case e : ecount++; case a : case i : case o : case u : vowels++; break; default: other++; }//end switch cin.get(ch); }//end while cout << ecount <<, << vowels <<, << other << endl; 25

26 Practice! Convert these nested if/else statements to a switch statement: if (rank==1 rank==2) cout << "Lower division \n"; else { if (rank==3 rank==4) cout << "Upper division \n"; else { if (rank==5) cout << "Graduate student \n"; else cout << "Invalid rank \n"; } } 26

27 while statement do while statement for statement Structuring input loops REPETITION STATEMENTS 27

28 Repetition Statements The C++ programming language supports the implementation of repetition with: while statements do/while statements for statements 28

29 The while statement? false while (expression) statement; true while (expression) { statement block } 29

30 The do/while statement true? false do statement; while (expression) do { statement block } while (expression) 30

31 Practice! #include <iostream> using namespace std; int main() { int n=4; while(n>0) { cout << n << endl; --n; } cout << value of n outside while is << n << endl; return 0; } Program Trace: Output? 31

32 The for statement initalize increment/ decrement statement(s)? true false 32

33 The for statement for(initialization; expression; increment/decrement) statement; for(initialization; expression; increment/decrement) { statement; statement; } 33

34 The for statement - examples //sum integers from //1 to 10 inclusive #include<iostream> using namespace std; int main() { int sum=0; for(int i=1;i<11;++i) { sum = sum + i; } } cout << sum << endl; return 0; Alternate solution: //sum integers from //1 to 10 #include<iostream> using namespace std; int main() { } int sum=0; for(int i=1;i<=10;i++) sum = sum + i; cout << sum << endl; return 0; 34

35 The for statement - example //sum odd integers from //1 to n inclusive #include<iostream> using namespace std; int main() { int sum=0, n; cout << "enter non-negative integer: "; cin >> n; for(int i=1;i<=n;i+=2) sum = sum + i cout << sum << endl; return 0; } 35

36 The for statement - example //sum odd integers from //1 to n inclusive //Alternate Solution #include<iostream> using namespace std; int main() { int sum=0, n; cout << "enter non-negative integer: "; cin >> n; for(int i=1;i<=n;++i) { if(i%2) sum = sum + i; } cout << sum << endl; return 0; } 36

37 The break statement break; terminates loop execution continues with the first statement following the loop Example: What is the output? for(int i-0; i<=10; ++i) { if(i%2) break; cout << i << endl; } 37

38 The continue statement q continue; forces next iteration of the loop, skipping any remaining statements in the loop Example: What is the output? for(int i-0; i<=10; ++i) { if(i%2) continue; cout << i << endl; } 38

39 Practice! //This while loop calculates n! int nfact=1, n; cout << "enter positive integer "; cin >> n; while(n > 1) { nfact = nfact*n; n--; } cout << n << "! = " << nfact << endl; //What is the output for n=5? 39

40 Structuring Input Loops Ø Repetition is useful when inputting data from standard input or from a file. Ø Common repetition structures: Ø counter-controlled Ø sentinel-controlled Ø end-of-data controlled 40

41 Counter-controlled Repetition Structure i 0 while i < = counter input data value //Do something with data value increment i end while 41

42 Sentinel-controlled Repetition Structure input data value while data value! = sentinel value //Do something with data value input next data value end while 42

43 eof()-controlled Repetition Structure input data value while end-of-file is not true //Do something with input data input next data value end while 43

### 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

### 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

### 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

### What is the consequences of no break statement in a case.

REVIEW DID YOU THINK ABOUT THE SUBTLE ISSUES HERE The Example using the switch statement. PLAY COMPUTER in class show in a table the values of the variables for the given input!!!! char ch; int ecount=0,

### 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

### 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

### 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

### 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.

### The C++ Language. Loops. ! Recall that a loop is another of the four basic programming language structures

The C++ Language Loops Loops! Recall that a loop is another of the four basic programming language structures Repeat statements until some condition is false. Condition False True Statement1 2 1 Loops

### 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

### 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

### 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

### Simple C++ Programs. Engineering Problem Solving with C++, Etter/Ingber. Dev-C++ Dev-C++ Windows Friendly Exit. The C++ Programming Language

Simple C++ Programs Engineering Problem Solving with C++, Etter/Ingber Chapter 2 Simple C++ Programs Program Structure Constants and Variables C++ Operators Standard Input and Output Basic Functions from

### Problem Solving With C++

Dept. of Geomatics Eng. University of Tehran Cell: 0912 132 5823 Email: marajabi@ut.ac.ir http://www.marajabi.com Unfinished Business Casts (force an expression to be of a specific type) #include

### 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

### Basics of I/O Streams and File I/O

Basics of This is like a cheat sheet for file I/O in C++. It summarizes the steps you must take to do basic I/O to and from files, with only a tiny bit of explanation. It is not a replacement for reading

### Introduction to Programming (in C++) Loops. Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC

Introduction to Programming (in C++) Loops Jordi Cortadella, Ricard Gavaldà, Fernando Orejas Dept. of Computer Science, UPC Example Assume the following specification: Input: read a number N > 0 Output:

### Example. Introduction to Programming (in C++) Loops. The while statement. Write the numbers 1 N. Assume the following specification:

Example Introduction to Programming (in C++) Loops Assume the following specification: Input: read a number N > 0 Output: write the sequence 1 2 3 N (one number per line) Jordi Cortadella, Ricard Gavaldà,

### 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

### 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,

### A brief introduction to C++ and Interfacing with Excel

A brief introduction to C++ and Interfacing with Excel ANDREW L. HAZEL School of Mathematics, The University of Manchester Oxford Road, Manchester, M13 9PL, UK CONTENTS 1 Contents 1 Introduction 3 1.1

### 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

### 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)

### Engineering Problem Solving with C++, Etter

Engineering Problem Solving with C++, Etter Chapter 7 Strings 12-11-13 1 Strings Character Strings The string Class. 2 C style strings functions defined in cstring CHARACTER STRINGS 3 C Style Character

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

### Computer 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,

### 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

### The University of Alabama in Huntsville Electrical and Computer Engineering CPE 112 01 Test #4 November 20, 2002. True or False (2 points each)

True or False (2 points each) The University of Alabama in Huntsville Electrical and Computer Engineering CPE 112 01 Test #4 November 20, 2002 1. Using global variables is better style than using local

### PROBLEM 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

### Conditions & 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

### 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

### 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)

### 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,

### 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

### 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).

### An Incomplete C++ Primer. University of Wyoming MA 5310

An Incomplete C++ Primer University of Wyoming MA 5310 Professor Craig C. Douglas http://www.mgnet.org/~douglas/classes/na-sc/notes/c++primer.pdf C++ is a legacy programming language, as is other languages

### 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

### 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

### 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

### I 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

### Storage Classes CS 110B - Rule Storage Classes Page 18-1 \handouts\storclas

CS 110B - Rule Storage Classes Page 18-1 Attributes are distinctive features of a variable. Data type, int or double for example, is an attribute. Storage class is another attribute. There are four storage

### 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

### 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

### El Dorado Union High School District Educational Services

El Dorado Union High School District Course of Study Information Page Course Title: ACE Computer Programming II (#495) Rationale: A continuum of courses, including advanced classes in technology is needed.

### 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

### Unit 6. Loop statements

Unit 6 Loop statements Summary Repetition of statements The while statement Input loop Loop schemes The for statement The do statement Nested loops Flow control statements 6.1 Statements in Java Till now

### Syllabus OBJECT ORIENTED PROGRAMMING C++

1 Syllabus OBJECT ORIENTED PROGRAMMING C++ 1. Introduction : What is object oriented programming? Why do we need objectoriented. Programming characteristics of object-oriented languages. C and C++. 2.

### 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;

### 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

### 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

### Example of a Java program

Example of a Java program class SomeNumbers static int square (int x) return x*x; public static void main (String[] args) int n=20; if (args.length > 0) // change default n = Integer.parseInt(args[0]);

### TECHNOLOGY Computer Programming II Grade: 9-12 Standard 2: Technology and Society Interaction

Standard 2: Technology and Society Interaction Technology and Ethics Analyze legal technology issues and formulate solutions and strategies that foster responsible technology usage. 1. Practice responsible

### 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

### Curriculum Map. Discipline: Computer Science Course: C++

Curriculum Map Discipline: Computer Science Course: C++ August/September: How can computer programs make problem solving easier and more efficient? In what order does a computer execute the lines of code

### C++ Programming: From Problem Analysis to Program Design, Fifth Edition. Chapter 3: Input/Output

C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 3: Input/Output Objectives In this chapter, you will: Learn what a stream is and examine input and output streams Explore

### 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

### C++ Input/Output: Streams

C++ Input/Output: Streams 1 The basic data type for I/O in C++ is the stream. C++ incorporates a complex hierarchy of stream types. The most basic stream types are the standard input/output streams: istream

### 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

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

### 7.7 Case Study: Calculating Depreciation

7.7 Case Study: Calculating Depreciation 1 7.7 Case Study: Calculating Depreciation PROBLEM Depreciation is a decrease in the value over time of some asset due to wear and tear, decay, declining price,

### Basic Programming and PC Skills: Basic Programming and PC Skills:

Texas University Interscholastic League Contest Event: Computer Science The contest challenges high school students to gain an understanding of the significance of computation as well as the details of

### 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

### C++ Language Tutorial

cplusplus.com C++ Language Tutorial Written by: Juan Soulié Last revision: June, 2007 Available online at: http://www.cplusplus.com/doc/tutorial/ The online version is constantly revised and may contain

### Moving from C++ to VBA

Introduction College of Engineering and Computer Science Mechanical Engineering Department Mechanical Engineering 309 Numerical Analysis of Engineering Systems Fall 2014 Number: 15237 Instructor: Larry

### Grade 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

### Sequential Program Execution

Sequential Program Execution Quick Start Compile step once always g++ -o Realtor1 Realtor1.cpp mkdir labs cd labs Execute step mkdir 1 Realtor1 cd 1 cp../0/realtor.cpp Realtor1.cpp Submit step cp /samples/csc/155/labs/1/*.

### Iteration CHAPTER 6. Topic Summary

CHAPTER 6 Iteration TOPIC OUTLINE 6.1 while Loops 6.2 for Loops 6.3 Nested Loops 6.4 Off-by-1 Errors 6.5 Random Numbers and Simulations 6.6 Loop Invariants (AB only) Topic Summary 6.1 while Loops Many

### 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

### Member Functions of the istream Class

Member Functions of the istream Class The extraction operator is of limited use because it always uses whitespace to delimit its reads of the input stream. It cannot be used to read those whitespace characters,

### COMPUTER 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

### PIC 10A. Lecture 7: Graphics II and intro to the if statement

PIC 10A Lecture 7: Graphics II and intro to the if statement Setting up a coordinate system By default the viewing window has a coordinate system already set up for you 10-10 10-10 The origin is in the

### AppendixA1A1. Java Language Coding Guidelines. A1.1 Introduction

AppendixA1A1 Java Language Coding Guidelines A1.1 Introduction This coding style guide is a simplified version of one that has been used with good success both in industrial practice and for college courses.

### Senem Kumova Metin & Ilker Korkmaz 1

Senem Kumova Metin & Ilker Korkmaz 1 A loop is a block of code that can be performed repeatedly. A loop is controlled by a condition that is checked each time through the loop. C supports two categories

### Compiler Construction

Compiler Construction Regular expressions Scanning Görel Hedin Reviderad 2013 01 23.a 2013 Compiler Construction 2013 F02-1 Compiler overview source code lexical analysis tokens intermediate code generation

### Comp151. Definitions & Declarations

Comp151 Definitions & Declarations Example: Definition /* reverse_printcpp */ #include #include using namespace std; int global_var = 23; // global variable definition void reverse_print(const

### 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

### Computer Programming I

Computer Programming I Levels: 10-12 Units of Credit: 1.0 CIP Code: 11.0201 Core Code: 35-02-00-00-030 Prerequisites: Secondary Math I, Keyboarding Proficiency, Computer Literacy requirement (e.g. Exploring

### Learning Computer Programming using e-learning as a tool. A Thesis. Submitted to the Department of Computer Science and Engineering.

Learning Computer Programming using e-learning as a tool. A Thesis Submitted to the Department of Computer Science and Engineering of BRAC University by Asharf Alam Student ID: 03101011 Md. Saddam Hossain

DalePhatANS_complete 8/18/04 10:30 AM Page 1049 Answers to Selected Exercises Chapter 1 Exam Preparation Exercises 1. a. v, b. i, c. viii, d. iii, e. iv, f. vii, g. vi, h. ii. 2. Analysis and specification,

### 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

### 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

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

### 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

### 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

### 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

### Passing 1D arrays to functions.

Passing 1D arrays to functions. In C++ arrays can only be reference parameters. It is not possible to pass an array by value. Therefore, the ampersand (&) is omitted. What is actually passed to the function,

### ECE 3401 Lecture 7. Concurrent Statements & Sequential Statements (Process)

ECE 3401 Lecture 7 Concurrent Statements & Sequential Statements (Process) Concurrent Statements VHDL provides four different types of concurrent statements namely: Signal Assignment Statement Simple Assignment

### ARIZONA CTE CAREER PREPARATION STANDARDS & MEASUREMENT CRITERIA SOFTWARE DEVELOPMENT, 15.1200.40

SOFTWARE DEVELOPMENT, 15.1200.40 STANDARD 1.0 APPLY PROBLEM-SOLVING AND CRITICAL THINKING SKILLS TO INFORMATION 1.1 Describe methods of establishing priorities 1.2 Prepare a plan of work and schedule information

### Ch 7-1. Object-Oriented Programming and Classes

2014-1 Ch 7-1. Object-Oriented Programming and Classes May 10, 2014 Advanced Networking Technology Lab. (YU-ANTL) Dept. of Information & Comm. Eng, Graduate School, Yeungnam University, KOREA (Tel : +82-53-810-2497;

### #820 Computer Programming 1A

Computer Programming I Levels: 10-12 Units of Credit: 1.0 CIP Code: 11.0201 Core Code: 35-02-00-00-030 Prerequisites: Secondary Math I, Keyboarding Proficiency, Computer Literacy requirement Semester 1

### Fundamentals 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

### Notes 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)

### Chapter 2 Introduction to Java programming

Chapter 2 Introduction to Java programming 1 Keywords boolean if interface class true char else package volatile false byte final switch while throws float private case return native void protected break

### CSC 221: Computer Programming I. Fall 2011

CSC 221: Computer Programming I Fall 2011 Python control statements operator precedence importing modules random, math conditional execution: if, if-else, if-elif-else counter-driven repetition: for conditional

### Java 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