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

Save this PDF as:

Size: px
Start display at page:

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

## Transcription

1 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 right value <= // true if left value is less than OR EQUAL to the right value > // true if left value is greater than the right value >= // true if left value is greater than OR EQUAL to the right value Logical Operators! // inverts true to false or false to true && // boolean AND // boolean OR Precedence Rules (from highest to lowest priority) - Arithmetic operators (i.e. ++,--,+,-,*,/, ) - Boolean operators (i.e. <, >, <=, >=) - ==,!= - && - Note: Integer values can be used as boolean values - 0 is considered as false and non- zero is considered as true - For this class, we should not use numbers for boolean values. All boolean expressions must be bool types. If- else statements Ability to execute two alternative statements based on the value of a Boolean Expression. if (Boolean Expression) { // code1 else { // code2 - Notice the {. This allows many statements to be executed within a block. - Without {, only the following statement will be executed and other statements are considered outside the block statement. Multi- way If- else Statements Multiple if- else statements can allow the program to execute many branches.

2 int x = 3; if (x == 1) cout << x equals 1 << endl; else if (x == 2) cout << x equals 2 << endl; else if (x == 3) cout << x equals 3 <<endl; else cout << x does not equal 1, 2, or 3 << endl; Switch statements - Another way to write Multi- way if- else statements are switch statements. - A switch statement can use either an integer type, bool, char, or enum. - The break statement tells the compiler that it s the end of a case. - Without the break statement, the compiler will execute the statements until a break is reached. int a = 3; switch (a) { case 1: cout << x equals 1 << endl; case 2: cout << x equals 2 << endl; case 3: cout << x equals 3 << endl; default: cout << x does not equal 1, 2, or 3 << endl; It is possible to have many cases refer to the same statements. int a = 3; switch (a) { case 1: case 2: cout << x equals 1 or 2 << endl; case 3: cout << x equals 3 << endl; default: cout << x does not equal 1, 2, or 3 << endl;

3 Embedded if- else statements Within a block statement, another if statement can be written. int x = 7; if (x >= 5) { cout << x > 5 << endl; if (x == 5) { cout << x == 5 << endl; else { cout << x > 5 << end; While loop while (Boolean Expression) { // code The code block will be executed as long as the boolean expression evaluates to true. Do- while Loop do { //code while (Boolean Expression); Useful if you want to execute a block of code at least once. For Loop for (initialization; boolean expression; update) { //code - Legal to leave the init, boolean expression, and/or update statement empty. - Considered bad style to leave any of them blank. Nested Loops Within a loop s block, other loops can be defined. for (int i = 0; i < 10; i++) { cout << i = << i << endl; for (int j = 0; j < 10; j++) { cout << j = << j << endl; The above nested loop is an example of O(n 2 ), where n = 10 in this case.

4 Continue and break in loops - continue statement can be used to stop the current execution of statements within the block and jump to the next iteration of the current loop. - break statement can be used to break out of the current loop and continue execution after the end of the loop. Call Stack When functions are called, they are maintained in a call stack The call stack consists of one or more frames - An instance of the function. - Contains information such as parameters, return values, and local variables. Each frame also keeps track of the frame pointer for the function that called it. Therefore, when the function finishes execution, it gets popped from the stack and returns to the function that called it so it can continue execution. Recursion When a function contains a call to itself. Factorial N! = N * (N 1) * (N 2) * * 3 * 2 * 1 Note: 0! = 1, 1! = 1 int factorial (int n) { if (n <= 1) // base case return 1; return n * factorial(n 1); Fibonacci f(n) = f(n- 1) + f(n- 2)). f(0) = 0, f(1) = 1, f(2) = 1, f(3) = 2, f(4) = 3, int fibonacci(int n) { if (n == 1) { return 1; if (n == 0) { return 0; retrun fibonacci(n-2) + fibonacci(n-1);

5 Tail Recursion When there is no other computation to do once a value is returned. int factorialtail(int n, int product) { if (n == 1) return product; return factorialtail(n - 1, product * n); Stack Overflow - Happens when a program crashes due to running out of memory in its call stack. Enumerations - Enumeration is a type whose values are defined by a list of constants of type int. - You can define enumeration types to any int value. enum Month {JAN = 1, FEB = 2, MARCH = 3, APRIL = 4, MAY = 5, JUNE = 6, JULY = 7, AUG = 8, SEP = 9, OCT = 10, NOV = 11, DEC = 12; Note, without defining the values, it starts with 0 and always increments the previous enum by 1. enum Month { JAN, FEB, MARCH, APRIL, MAY, JUNE, JULY, AUG, SEP, OCT, NOV, DEC ; // JAN = 0 à DEC = 11 Note: It s good to define enums in an appropriate header file so other source files may use it. int month = 3; switch (month) case DEC: case JAN: case FEB: cout << It s winter time! << endl; case MARCH: case APRIL: case MAY: cout << It s spring time! << endl; case JUNE: case JULY: case AUG: cout << It s summer time! << endl; case SEP: case OCT:

6 case NOV: cout << It s fall! << endl; default: cout << Not a valid month << endl;

### Chapter 4 Operators & Arithmetic

Chapter 4 Operators & Arithmetic 4-1 Arithmetic in C++ Arithmetic expressions can be made up of constants, variables, operators and parentheses. The arithmetic operators in C++ are as follows + (addition)

### Introduction to Programming

Introduction to Programming SS 2012 Adrian Kacso, Univ. Siegen adriana.dkacsoa@duni-siegena.de Tel.: 0271/740-3966, Office: H-B 8406 Stand: April 25, 2012 Betriebssysteme / verteilte Systeme Introduction

### HOSPIRA (HSP US) HISTORICAL COMMON STOCK PRICE INFORMATION

30-Apr-2004 28.35 29.00 28.20 28.46 28.55 03-May-2004 28.50 28.70 26.80 27.04 27.21 04-May-2004 26.90 26.99 26.00 26.00 26.38 05-May-2004 26.05 26.69 26.00 26.35 26.34 06-May-2004 26.31 26.35 26.05 26.26

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

### CSCI 123 INTRODUCTION TO PROGRAMMING CONCEPTS IN C++

Brad Rippe CSCI 123 INTRODUCTION TO PROGRAMMING CONCEPTS IN C++ Recursion Recursion CHAPTER 14 Overview 14.1 Recursive Functions for Tasks 14.2 Recursive Functions for Values 14.3 Thinking Recursively

### Median and Average Sales Prices of New Homes Sold in United States

Jan 1963 \$17,200 (NA) Feb 1963 \$17,700 (NA) Mar 1963 \$18,200 (NA) Apr 1963 \$18,200 (NA) May 1963 \$17,500 (NA) Jun 1963 \$18,000 (NA) Jul 1963 \$18,400 (NA) Aug 1963 \$17,800 (NA) Sep 1963 \$17,900 (NA) Oct

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

### What Is Recursion? 5/12/10 1. CMPSC 24: Lecture 13 Recursion. Lecture Plan. Divyakant Agrawal Department of Computer Science UC Santa Barbara

CMPSC 24: Lecture 13 Recursion Divyakant Agrawal Department of Computer Science UC Santa Barbara 5/12/10 1 Lecture Plan Recursion General structure of recursive soluions Why do recursive soluions terminate?

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

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

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

### THE UNIVERSITY OF BOLTON

JANUARY Jan 1 6.44 8.24 12.23 2.17 4.06 5.46 Jan 2 6.44 8.24 12.24 2.20 4.07 5.47 Jan 3 6.44 8.24 12.24 2.21 4.08 5.48 Jan 4 6.44 8.24 12.25 2.22 4.09 5.49 Jan 5 6.43 8.23 12.25 2.24 4.10 5.50 Jan 6 6.43

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

### Branching. We ll continue to look at the basics of writing C++ programs including. Overview

Branching Overview We ll continue to look at the basics of writing C++ programs including Boolean Expressions (need to know this before we can using branching and looping!) Branching J.S. Bradbury CSCI

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

### What Is Recursion? Recursion. Binary search example postponed to end of lecture

Recursion Binary search example postponed to end of lecture What Is Recursion? Recursive call A method call in which the method being called is the same as the one making the call Direct recursion Recursion

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

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

### Recursion. Slides. Programming in C++ Computer Science Dept Va Tech Aug., 2001. 1995-2001 Barnette ND, McQuain WD

1 Slides 1. Table of Contents 2. Definitions 3. Simple 4. Recursive Execution Trace 5. Attributes 6. Recursive Array Summation 7. Recursive Array Summation Trace 8. Coding Recursively 9. Recursive Design

### The first step in solving a problem recursively is to formulate a recursive definition of the problem.

Chapter 8 Recursion The subject of this chapter is recursion, an implicit application of the stack ADT. A recursive method is a method that carries out its task by making a call(s) to itself. Each recursive

### MS Visual C++ Introduction. Quick Introduction. A1 Visual C++

MS Visual C++ Introduction 1 Quick Introduction The following pages provide a quick tutorial on using Microsoft Visual C++ 6.0 to produce a small project. There should be no major differences if you are

### Exercise 4. Informatik I für D-MAVT (FS 2016) Logical Operators and Branching. M. Gross, ETH Zürich, 2016

Exercise 4 Logical Operators and Branching Informatik I für D-MAVT (FS 2016) Übung 2! war gut gelöst 2 Übung 2! war gut gelöst 2 Übung 2! war gut gelöst 2 Agenda Branching Relational operators Logical

### Exercise 4 Logical Operators & Branching

Exercise 4 Logical Operators & Branching Informatik I für D-MAVT (FS 2013) Christian Schumacher chschuma@inf.ethz.ch Agenda Branching relational operators logical expressions: and, or, not if, else if,

### AT&T Global Network Client for Windows Product Support Matrix January 29, 2015

AT&T Global Network Client for Windows Product Support Matrix January 29, 2015 Product Support Matrix Following is the Product Support Matrix for the AT&T Global Network Client. See the AT&T Global Network

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

### NAV HISTORY OF DBH FIRST MUTUAL FUND (DBH1STMF)

NAV HISTORY OF DBH FIRST MUTUAL FUND () Date NAV 11-Aug-16 10.68 8.66 0.38% -0.07% 0.45% 3.81% 04-Aug-16 10.64 8.66-0.19% 0.87% -1.05% 3.76% 28-Jul-16 10.66 8.59 0.00% -0.34% 0.34% 3.89% 21-Jul-16 10.66

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

### Programming with Recursion. What Is Recursion?

Chapter 7 Programming with Recursion Fall 2013 Yanjun Li CS2200 1 What Is Recursion? How is recursion like a set of Russian dolls? Fall 2013 Yanjun Li CS2200 2 What Is Recursion? Recursive call A method

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

### Analysis One Code Desc. Transaction Amount. Fiscal Period

Analysis One Code Desc Transaction Amount Fiscal Period 57.63 Oct-12 12.13 Oct-12-38.90 Oct-12-773.00 Oct-12-800.00 Oct-12-187.00 Oct-12-82.00 Oct-12-82.00 Oct-12-110.00 Oct-12-1115.25 Oct-12-71.00 Oct-12-41.00

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

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

### COMPARISON OF FIXED & VARIABLE RATES (25 YEARS) CHARTERED BANK ADMINISTERED INTEREST RATES - PRIME BUSINESS*

COMPARISON OF FIXED & VARIABLE RATES (25 YEARS) 2 Fixed Rates Variable Rates FIXED RATES OF THE PAST 25 YEARS AVERAGE RESIDENTIAL MORTGAGE LENDING RATE - 5 YEAR* (Per cent) Year Jan Feb Mar Apr May Jun

### COMPARISON OF FIXED & VARIABLE RATES (25 YEARS) CHARTERED BANK ADMINISTERED INTEREST RATES - PRIME BUSINESS*

COMPARISON OF FIXED & VARIABLE RATES (25 YEARS) 2 Fixed Rates Variable Rates FIXED RATES OF THE PAST 25 YEARS AVERAGE RESIDENTIAL MORTGAGE LENDING RATE - 5 YEAR* (Per cent) Year Jan Feb Mar Apr May Jun

### Adjusted/Modified by Nicole Tobias. Chapter 2: Basic Elements of C++

Adjusted/Modified by Nicole Tobias Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with functions, special symbols, and identifiers in C++ Explore simple data types

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

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

### Which of the following is the correct operator to compare two variables? A. := B. = C. equal D. ==

Group 1 Question 1. What is the correct value to return to the operating system upon the successful completion of a program? A. -1 B. 1 C. 0 D. Programs do not return a value. Question 2. What is the only

### FORM 1 (Please put your name, section # (10am- 001/2pm-002, and form # on the scantron!!!!) CS 161 Exam I:

FORM 1 (Please put your name, section # (10am- 001/2pm-002, and form # on the scantron!!!!) CS 161 Exam I: True (A)/False(B) (2 pts each): 1. The following statement is legal: cout >> Hello, my name is

### Programming with Recursion. What Is Recursion?

Chapter 7 Programming with Recursion Spring 2015 Yanjun Li CS2200 1 What Is Recursion? How is recursion like a set of Russian dolls? Spring 2015 Yanjun Li CS2200 2 What Is Recursion? Recursive call A method

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

### C++FA 3.1 OPTIMIZING C++

C++FA 3.1 OPTIMIZING C++ Ben Van Vliet Measuring Performance Performance can be measured and judged in different ways execution time, memory usage, error count, ease of use and trade offs usually have

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

### Data Structure with C

Subject: Data Structure with C Topic : Tree Tree A tree is a set of nodes that either:is empty or has a designated node, called the root, from which hierarchically descend zero or more subtrees, which

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

### Chapter 4 C Program Control

Chapter 4 C Program Control Objectives of this chapter: Repetitions will be considered in greater detail for.. repetition do while repetition Also multiple selection switch case statement will be learned.

### Chapter 8. Arithmetic in C++

Christian Jacob Chapter 8 Arithmetic in C++ 8.1 The C++ Vocabulary 8.2 Variables and Types 8.2.1 Data Objects 8.2.2 Variables 8.2.3 Declaration of Variables 8.3 Elementary C++ Data Types 8.3.1 Integers

### 3. Backtracking: Postponing the Work (a) The Eight-Queens Puzzle (b) Review and Refinement (c) Analysis

Chapter 5 RECURSION 1. Introduction to Recursion (a) Stack Frames (b) Recursion Trees (c) Examples 2. Principles of Recursion 3. Backtracking: Postponing the Work (a) The Eight-Queens Puzzle (b) Review

### 6.096 Lab 1. Due: 7 January 12:30:00. September 20, 2011

6.096 Lab 1 Due: 7 January 1:30:00 September 0, 011 1 Additional Material 1.1 Constants A constant is an expressions with a fixed value. Kinds of constants: Literals: used to express particular values

### Chapter 5 Functions. Introducing Functions

Chapter 5 Functions 1 Introducing Functions A function is a collection of statements that are grouped together to perform an operation Define a function Invoke a funciton return value type method name

### For the next three questions, consider the class declaration: Member function implementations put inline to save space.

Instructions: This homework assignment focuses on basic facts regarding classes in C++. Submit your answers via the Curator System as OQ4. For the next three questions, consider the class declaration:

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

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

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

### Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups:

JAVA OPERATORS GENERAL Java provides a rich set of operators to manipulate variables. We can divide all the Java operators into the following groups: Arithmetic Operators Relational Operators Bitwise Operators

### A C# program structure About variables Predefined Data Types Flow Control Enumerations Arrays Namespaces The Main() method. Console IO Comments

Basics of C# What are we going to study? A C# program structure About variables Predefined Data Types Flow Control Enumerations Arrays Namespaces The Main() method Compilation of C# program Console IO

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

### Module 2 Stacks and Queues: Abstract Data Types

Module 2 Stacks and Queues: Abstract Data Types A stack is one of the most important and useful non-primitive linear data structure in computer science. It is an ordered collection of items into which

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

### 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 C Programming Language course syllabus associate level

TECHNOLOGIES The C Programming Language course syllabus associate level Course description The course fully covers the basics of programming in the C programming language and demonstrates fundamental programming

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

### Introduction to C for Atmel XMega

Introduction to C for Atmel XMega 1 Menu Overview of C Basics Variables, Types, and Definitions Conditionals Ports and Registers Interrupts Pointers Strongly Using C with Assembly 2 1 Overview of C Basics

### Common Data Structures

Data Structures 1 Common Data Structures Arrays (single and multiple dimensional) Linked Lists Stacks Queues Trees Graphs You should already be familiar with arrays, so they will not be discussed. Trees

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

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

### Programming for MSc Part I

Herbert Martin Dietze University of Buckingham herbert@the-little-red-haired-girl.org July 24, 2001 Abstract The course introduces the C programming language and fundamental software development techniques.

### Control Structure. Pseudocode: Input number If number is even Then Print even Else print odd. Flowchart: Begin. End. Print Odd. number even?

Control Structure Normally, a program is executed in a sequential manner.however, in many cases, a program has to choose among alternative statements C++ provides constructs that enable the programmer

### Introduction to Programming

Introduction to Programming SS 2012 Adrian Kacso, Univ. Siegen adriana.dkacsoa@duni-siegena.de Tel.: 0271/740-3966, Office: H-B 8406 Stand: April 25, 2012 Betriebssysteme / verteilte Systeme Introduction

### 13 Classes & Objects with Constructors/Destructors

13 Classes & Objects with Constructors/Destructors 13.1 Introduction In object oriented programming, the emphasis is on data rather than function. Class is a way that binds the data & function together.

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

### DATES OF PUBLICATION FOR ISSUES OF THE JOURNAL RHODORA (Volume 1-116)

DATES OF PUBLICATION FOR ISSUES OF THE JOURNAL RHODORA (Volume 1-116) Prepared by JAMES L. REVEAL and KANCHI N. GANDHI Some dates of publication were not reported in the journal. These are marked with

### 6.087 Lecture 3 January 13, 2010

6.087 Lecture 3 January 13, 2010 Review Blocks and Compound Statements Control Flow Conditional Statements Loops Functions Modular Programming Variable Scope Static Variables Register Variables 1 Review:

### Calling the Function. Two Function Declarations Here is a function declared as pass by value. Why use Pass By Reference?

Functions in C++ Let s take a look at an example declaration: Lecture 2 long factorial(int n) Functions The declaration above has the following meaning: The return type is long That means the function

Operator Overloading Lecture 8 Operator Overloading C++ feature that allows implementer-defined classes to specify class-specific function for operators Benefits allows classes to provide natural semantics

### Case 2:08-cv-02463-ABC-E Document 1-4 Filed 04/15/2008 Page 1 of 138. Exhibit 8

Case 2:08-cv-02463-ABC-E Document 1-4 Filed 04/15/2008 Page 1 of 138 Exhibit 8 Case 2:08-cv-02463-ABC-E Document 1-4 Filed 04/15/2008 Page 2 of 138 Domain Name: CELLULARVERISON.COM Updated Date: 12-dec-2007

### C++ Programming: From Problem Analysis to Program Design, Fifth Edition. Chapter 2: Basic Elements of C++

C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 2: Basic Elements of C++ Objectives In this chapter, you will: Become familiar with the basic components of a C++ program,

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

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

### CS1020E: DATA STRUCTURES AND ALGORITHMS I

CS1020E: DATA STRUCTURES AND ALGORITHMS I Tutorial 1 Basic C++, OOP Problem Solving (Week 3, starting 22 August 2016) 1. Evaluation Order (Note: You can use any other C++ code editor/compiler). Examine

### 14 MAKING DECISIONS IN C

14 MAKING DECISIONS IN C 14.1 INTRODUCTION So far we have seen that in C programs the instructions are executed in the same order in which they appear in the program. Each instruction is executed once

### Example: Array Access

ECE232: Hardware Organization and Design Part 7: MIPS Instructions III http://www.ecs.umass.edu/ece/ece232/ Adapted from Computer Organization and Design, Patterson & Hennessy, UCB Example: Array Access

### CENTERPOINT ENERGY TEXARKANA SERVICE AREA GAS SUPPLY RATE (GSR) JULY 2015. Small Commercial Service (SCS-1) GSR

JULY 2015 Area (RS-1) GSR GSR (LCS-1) Texarkana Incorporated July-15 \$0.50690/Ccf \$0.45450/Ccf \$0.00000/Ccf \$2.85090/MMBtu \$17.52070/MMBtu Texarkana Unincorporated July-15 \$0.56370/Ccf \$0.26110/Ccf \$1.66900/Ccf

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

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

### 8051 Programming. The 8051 may be programmed using a low-level or a high-level programming language.

8051 Programming The 8051 may be programmed using a low-level or a high-level programming language. Low-Level Programming Assembly language programming writes statements that the microcontroller directly

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

### Advanced C++ Exception Handling Topic #5

Advanced C++ Exception Handling Topic #5 CS202 5-1 CS202 5-2 Exception Handling Throwing an Exception Detecting an Exception Catching an Exception Examine an Example using Classes and Operator Overloading

### 2. Place the following computers in order from oldest to most recent. _middle ABC _oldest Analytical Engine _newest ENIAC

Chapter 1 1. Match the following people with their contribution to the field of Computer Science, where a name can be used more than once. A. John Atanasoff and Cilfford Berry B. Augusta Ada Byron C. Charles

### C++ INTERVIEW QUESTIONS

C++ INTERVIEW QUESTIONS http://www.tutorialspoint.com/cplusplus/cpp_interview_questions.htm Copyright tutorialspoint.com Dear readers, these C++ Interview Questions have been designed specially to get

### CpSc212 Goddard Notes Chapter 6. Yet More on Classes. We discuss the problems of comparing, copying, passing, outputting, and destructing

CpSc212 Goddard Notes Chapter 6 Yet More on Classes We discuss the problems of comparing, copying, passing, outputting, and destructing objects. 6.1 Object Storage, Allocation and Destructors Some objects

### CS 2412 Data Structures. Chapter 2 Stacks and recursion

CS 2412 Data Structures Chapter 2 Stacks and recursion 1 2.1 Stacks A stack is a data structure in which all insertions and deletions of entries are made at one end, called top of the stack. Examples:

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

### C++ Keywords. If/else Selection Structure. Looping Control Structures. Switch Statements. Example Program

C++ Keywords There are many keywords in C++ that are not used in other languages. bool, const_cast, delete, dynamic_cast, const, enum, extern, register, sizeof, typedef, explicit, friend, inline, mutable,

### Local workspace of a subroutine: Recursion and recursive subroutines:

Local workspace of a subroutine: A number of temporary memory locations required by the subroutine for temporary private variables used in addition to available data registers. Recursion and recursive

### CS 101: Computer Programming and Utilizati on

CS 101: Computer Programming and Utilizati on Jul-Nov 2016 Bernard Menezes (cs101@cse.iitb.ac.in) Lecture 5: Conditional Execution About These Slides Based on Chapter 6 of the book An Introduction to Programming

### SYSTEMS PROGRAMMING C++ INTRODUCTION

Faculty of Computer Science / Institute of Systems Architecture / Operating Systems SYSTEMS PROGRAMMING C++ INTRODUCTION Alexander Warg WHY C++? C++ is the language that allows to express ideas from the

### Lecture 3 C Programming Language

Lecture 3 C Programming Language Summary of Lecture 3 streams error handling library functions break, continue, switch statements constants and macros C preprocessor (CPP) header files Streams Stdin, stdout