# QUIZ-II QUIZ-II. Chapter 5: Control Structures II (Repetition) Objectives. Objectives (cont d.) 20/11/2015. EEE 117 Computer Programming Fall

Size: px
Start display at page:

Download "QUIZ-II QUIZ-II. Chapter 5: Control Structures II (Repetition) Objectives. Objectives (cont d.) 20/11/2015. EEE 117 Computer Programming Fall-2015 1"

Transcription

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 division, if the denominator is zero, output an appropriate message.) The sample output follows: 3+4=7 C++ Programming: From Problem Analysis to Program Design, Sixth Edition 2 QUIZ-II Suppose that we want to write a program that analyzes students GPA. If the GPA is greater than or equal to 3.9, the student makes the dean s honor list. If the GPA is less than 2.00, the student is sent a warning letter indicating that the GPA is below the graduation requirement. C++ Programming: From Problem Analysis to Program Design, Sixth Edition 3 Chapter 5: Control Structures II (Repetition) Objectives In this chapter, you will: Learn about repetition (looping) control structures Explore how to construct and use countercontrolled, sentinel-controlled, flag-controlled, and EOF-controlled repetition structures Examine break and continue statements Discover how to form and use nested control structures Objectives (cont d.) In this chapter, you will (cont d.): Learn how to avoid bugs by avoiding patches Learn how to debug loops 5 6 Fall

2 Why Is Repetition Needed? Repetition allows efficient use of variables Can input, add, and average multiple numbers using a limited number of variables For example, to add five numbers: Declare a variable for each number, input the numbers and add the variables together Create a loop that reads a number into a variable and adds it to a variable that contains the sum of the numbers Structure Syntax of the while statement: statement can be simple or compound expression acts as a decision maker and is usually a logical expression statement is called the body of the loop The parentheses are part of the syntax i in previous Example 5-1 is called the loop control variable (LCV) Infinite loop: continues to execute endlessly Avoided by including statements in loop body that assure the exit condition is eventually false Fall

3 Case 1: Counter-Controlled while Loops When you know exactly how many times the statements need to be executed Use a counter-controlled while loop Case 2: Sentinel-Controlled while Loops Sentinel variable is tested in the condition Loop ends when sentinel is encountered Example 5-5: Telephone Digits Case 3: Flag-Controlled while Loops Example 5-5 provides an example of a sentinel-controlled loop(pg : 278) The program converts uppercase letters to their corresponding telephone digit case 'A': case 'B': case 'C': cout << 2 <<endl; case 'D': case 'E': case 'F': cout << 3 << endl; case 'G': case 'H': case 'I': cout << 4 << endl; case 'J': case 'K': case 'L': cout << 5 << endl; Flag-controlled while loop: uses a bool variable to control the loop Number Guessing Game Example 5-6 implements a number guessing game using a flag-controlled while loop (Pg:282) Uses the function rand of the header file cstd lib to generate a random number srand(time(0)); Num = rand()%100; rand() returns an int value between 0 and To convert to an integer >= 0 and < 100: rand() % Case 4: EOF-Controlled while Loops End-of-file (EOF)-controlled while loop: when it is difficult to select a sentinel value The logical value returned by cin can determine if there is no more input 18 Fall

4 Case 4: EOF-Controlled while Loops (cont d.) eof Function The function eof can determine the end of file status eof is a member of data type istream Syntax for the function eof: istreamvar is an input stream variable, such as cin More on Expressions in while Statements The expression in a while statement can be complex Example: while ((noofguesses < 5) && (!isguessed)) {... } Programming Example: Fibonacci Number Consider the following sequence of numbers: 1, 1, 2, 3, 5, 8, 13, 21, 34,... Called the Fibonacci sequence Given the first two numbers of the sequence (say, a1 and a2) n th number a n, n >= 3, of this sequence is given by: a n = a n-1 + a n Programming Example: Fibonacci Number (cont d.) Fibonacci sequence n th Fibonacci number a 2 = 1 a 1 = 1 Determine the n th number a n, n >= 3 Programming Example: Fibonacci Number (cont d.) Suppose a 2 = 6 and a 1 = 3 a 3 = a 2 + a 1 = = 9 a 4 = a 3 + a 2 = = 15 Write a program that determines the n th Fibonacci number, given the first two numbers Fall

5 Programming Example: Input and Output Input: first two Fibonacci numbers and the desired Fibonacci number Output: n th Fibonacci number Programming Example: Problem Analysis and Algorithm Design Algorithm: Get the first two Fibonacci numbers Get the desired Fibonacci number Get the position, n, of the number in the sequence Calculate the next Fibonacci number Add the previous two elements of the sequence Repeat Step 3 until the n th Fibonacci number is found Output the n th Fibonacci number Programming Example: Variables Algorithm Prompt the user for the first two numbers that is, previous1 and previous2 Read (input) the first two numbers into previous1 and previous2 Output the first two Fibonacci numbers Prompt the user for the position of the desired Fibonacci number Algorithm (cont d.) Read the position of the desired Fibonacci number into nthfibonacci if (nthfibonacci == 1) The desired Fibonacci number is the first Fibonacci number; copy the value of previous1 into current else if (nthfibonacci == 2) The desired Fibonacci number is the second Fibonacci number; copy the value of previous2 into current Algorithm (cont d.) else calculate the desired Fibonacci number as follows: Start by determining the third Fibonacci number Initialize counter to 3 to keep track of the calculated Fibonacci numbers. Calculate the next Fibonacci number, as follows: current = previous2 + previous1; Fall

6 Algorithm (cont d.) (cont d.) Assign the value of previous2 to previous1 Assign the value of current to previous2 Increment counter Repeat until Fibonacci number is calculated: while (counter <= nthfibonacci) { current = previous2 + previous1; previous1 = previous2; previous2 = current; counter++; } Algorithm (cont d.) Output the nthfibonacci number, which is current Structure for loop: called a counted or indexed for loop Syntax of the for statement: The initial statement, loop condition, and update statement are called for loop control statements Fall

7 The following is a semantic error: The following is a legal (but infinite) for loop: for (;;) cout << "Hello" << endl; Structure Syntax of a do...while loop: The statement executes first, and then the expression is evaluated As long as expression is true, loop continues To avoid an infinite loop, body must contain a statement that makes the expression false The statement can be simple or compound Loop always iterates at least once Fall

8 43 44 Choosing the Right Looping Structure All three loops have their place in C++ If you know or can determine in advance the number of repetitions needed, the for loop is the correct choice If you do not know and cannot determine in advance the number of repetitions needed, and it could be zero, use a while loop If you do not know and cannot determine in advance the number of repetitions needed, and it is at least one, use a do...while loop break and continue Statements break and continue alter the flow of control break statement is used for two purposes: To exit early from a loop Can eliminate the use of certain (flag) variables To skip the remainder of a switch structure After break executes, the program continues with the first statement after the structure break and continue Statements (cont d.) Nested Control Structures continue is used in while, for, and do while structures When executed in a loop It skips remaining statements and proceeds with the next iteration of the loop To create the following pattern: * ** *** **** ***** We can use the following code: for (i = 1; i <= 5 ; i++) { for (j = 1; j <= i; j++) cout << "*"; cout << endl; } Fall

9 Nested Control Structures (cont d.) What is the result if we replace the first for statement with this? Answer: for (i = 5; i >= 1; i--) ***** **** *** ** * Avoiding Bugs by Avoiding Patches Software patch Piece of code written on top of an existing piece of code Intended to fix a bug in the original code Some programmers address the symptom of the problem by adding a software patch Should instead resolve underlying issue Debugging Loops Summary Loops are harder to debug than sequence and selection structures Use loop invariant Set of statements that remains true each time the loop body is executed Most common error associated with loops is off-by-one C++ has three looping (repetition) structures: while, for, and do while while, for, and do are reserved words while and for loops are called pretest loops do...while loop is called a posttest loop while and for may not execute at all, but do...while always executes at least once Summary (cont d.) Summary (cont d.) while: expression is the decision maker, and statement is the body of the loop A while loop can be: Counter-controlled Sentinel-controlled EOF-controlled In the Windows console environment, the end-of-file marker is entered using Ctrl+z for loop: simplifies the writing of a countercontrolled while loop Putting a semicolon at the end of the for loop is a semantic error Executing a break statement in the body of a loop immediately terminates the loop Executing a continue statement in the body of a loop skips to the next iteration Fall

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

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

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

Engineering Problem Solving with C++, Etter/Ingber Chapter 3 Control Structures 1 Control structures Algorithm Development Conditional Expressions Selection Statements Repetition Statements Structuring

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

### Python Loops and String Manipulation

WEEK TWO Python Loops and String Manipulation Last week, we showed you some basic Python programming and gave you some intriguing problems to solve. But it is hard to do anything really exciting until

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

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

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

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

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

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

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

### Chapter 2: Elements of Java

Chapter 2: Elements of Java Basic components of a Java program Primitive data types Arithmetic expressions Type casting. The String type (introduction) Basic I/O statements Importing packages. 1 Introduction

### KS3 Computing Group 1 Programme of Study 2015 2016 2 hours per week

1 07/09/15 2 14/09/15 3 21/09/15 4 28/09/15 Communication and Networks esafety Obtains content from the World Wide Web using a web browser. Understands the importance of communicating safely and respectfully

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

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

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

### 16. Recursion. COMP 110 Prasun Dewan 1. Developing a Recursive Solution

16. Recursion COMP 110 Prasun Dewan 1 Loops are one mechanism for making a program execute a statement a variable number of times. Recursion offers an alternative mechanism, considered by many to be more

### River Dell Regional School District. Computer Programming with Python Curriculum

River Dell Regional School District Computer Programming with Python Curriculum 2015 Mr. Patrick Fletcher Superintendent River Dell Regional Schools Ms. Lorraine Brooks Principal River Dell High School

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

### WAYNESBORO AREA SCHOOL DISTRICT CURRICULUM INTRODUCTION TO COMPUTER SCIENCE (June 2014)

UNIT: Programming with Karel NO. OF DAYS: ~18 KEY LEARNING(S): Focus on problem-solving and what it means to program. UNIT : How do I program Karel to do a specific task? Introduction to Programming with

### Computer Science 217

Computer Science 217 Midterm Exam Fall 2009 October 29, 2009 Name: ID: Instructions: Neatly print your name and ID number in the spaces provided above. Pick the best answer for each multiple choice question.

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

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

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

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

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

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

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

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

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

### C# programming. Introduction. By Per Laursen

C# programming Introduction By Per Laursen Indhold The Programming Process... 3 Environment... 5 Statements... 7 Programming Fundamentals... 9 Types and Variables... 10 Simple data output on the screen...

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

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

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

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

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

### Regression Verification: Status Report

Regression Verification: Status Report Presentation by Dennis Felsing within the Projektgruppe Formale Methoden der Softwareentwicklung 2013-12-11 1/22 Introduction How to prevent regressions in software

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

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

Chapter 7: Software Development Stages Test your knowledge - answers 1. What is meant by constraints and limitations on program design? Constraints and limitations are based on such items as operational,

### Computers. An Introduction to Programming with Python. Programming Languages. Programs and Programming. CCHSG Visit June 2014. Dr.-Ing.

Computers An Introduction to Programming with Python CCHSG Visit June 2014 Dr.-Ing. Norbert Völker Many computing devices are embedded Can you think of computers/ computing devices you may have in your

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

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

### Chapter 1: Key Concepts of Programming and Software Engineering

Chapter 1: Key Concepts of Programming and Software Engineering Software Engineering Coding without a solution design increases debugging time - known fact! A team of programmers for a large software development

### Appendix K Introduction to Microsoft Visual C++ 6.0

Appendix K Introduction to Microsoft Visual C++ 6.0 This appendix serves as a quick reference for performing the following operations using the Microsoft Visual C++ integrated development environment (IDE):

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

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

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

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

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

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

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

### Chapter 9: Building Bigger Programs

Chapter 9: Building Bigger Programs How to Design Larger Programs Building something larger requires good software engineering. Design Top- down: Start from requirements, then identify the pieces to write,

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

### Common Beginner C++ Programming Mistakes

Common Beginner C++ Programming Mistakes This documents some common C++ mistakes that beginning programmers make. These errors are two types: Syntax errors these are detected at compile time and you won't

### 14:440:127 Introduction to Computers for Engineers. Notes for Lecture 06

14:440:127 Introduction to Computers for Engineers Notes for Lecture 06 Rutgers University, Spring 2010 Instructor- Blase E. Ur 1 Loop Examples 1.1 Example- Sum Primes Let s say we wanted to sum all 1,

### Introduction to Python

WEEK ONE Introduction to Python Python is such a simple language to learn that we can throw away the manual and start with an example. Traditionally, the first program to write in any programming language

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

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

### The Payroll Program. Payroll

The Program 1 The following example is a simple payroll program that illustrates most of the core elements of the C++ language covered in sections 3 through 6 of the course notes. During the term, a formal

### Practice Questions. CS161 Computer Security, Fall 2008

Practice Questions CS161 Computer Security, Fall 2008 Name Email address Score % / 100 % Please do not forget to fill up your name, email in the box in the midterm exam you can skip this here. These practice

### 1 Description of The Simpletron

Simulating The Simpletron Computer 50 points 1 Description of The Simpletron In this assignment you will write a program to simulate a fictional computer that we will call the Simpletron. As its name implies

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

### Figure 1: Graphical example of a mergesort 1.

CSE 30321 Computer Architecture I Fall 2011 Lab 02: Procedure Calls in MIPS Assembly Programming and Performance Total Points: 100 points due to its complexity, this lab will weight more heavily in your

### Section IV.1: Recursive Algorithms and Recursion Trees

Section IV.1: Recursive Algorithms and Recursion Trees Definition IV.1.1: A recursive algorithm is an algorithm that solves a problem by (1) reducing it to an instance of the same problem with smaller

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

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

### Module 10. Coding and Testing. Version 2 CSE IIT, Kharagpur

Module 10 Coding and Testing Lesson 23 Code Review Specific Instructional Objectives At the end of this lesson the student would be able to: Identify the necessity of coding standards. Differentiate between

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

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

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

### First Java Programs. V. Paúl Pauca. CSC 111D Fall, 2015. Department of Computer Science Wake Forest University. Introduction to Computer Science

First Java Programs V. Paúl Pauca Department of Computer Science Wake Forest University CSC 111D Fall, 2015 Hello World revisited / 8/23/15 The f i r s t o b l i g a t o r y Java program @author Paul Pauca

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

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