comp sci details

 comp sci info Composition

CSP2104-5107: Object-Oriented

Coding in C++

Lecture goal

Making Decisions

Prof. A. Taleb-Bendiab

Area 13. 213

a. [email protected] edu. au

Blackboard

Prof. A. Taleb-Bendiab, Unit: Object-Oriented Programming in C++, Code: CSP2104-5107, Address: 03, Day: 05/03/2013, Page: 1

Unit Review: Component 03

пЃ¬

So far …

пЃ¬

пЃ¬

пЃ¬

This kind of Lecture

пЃ¬

пЃ¬

пЃ¬

пЃ¬

пЃ¬

пЃ¬

пЃ¬

пЃ¬

Lecture 1: Introduction to OO

Spiel 2: Assessing C++ Expression

Use the in the event that and if-else statements

Employ nested in the event that statements

Prevent common stumbling blocks with if perhaps statements

Use the switch affirmation

Use the conditional operator

Utilize logical AND and the logical OR

Produce decisions with structure fields

Book:

пЃ¬

Object-Oriented Coding Using C++, Fourth Copy

Prof. A. Taleb-Bendiab, Unit: Object-Oriented Encoding in C++, Code: CSP2104-5107, Lecture: 03, Date: 05/03/2013, Page: 2

Using the if Statement #1

пЃ¬

C++ supports most standard control structures:

пЃ¬

if statement

if-else affirmation

switch affirmation

пЃ¬

Conditional operators

пЃ¬

пЃ¬

пЃ¬

пЃ¬

You can combine decisions using the reasonable AND

and OR operators

The Single-Alternative in the event

пЃ¬

пЃ¬

if: principal C++ variety structure declaration used to execute a single-alternative assortment

Syntax:

пЃ¬

if (Boolean expression)

 action if true

 else expression;

Prof. A. Taleb-Bendiab, Device: Object-Oriented Development in C++, Code: CSP2104-5107, Lecture: 03, Date: 05/03/2013, Page: several

Using the if perhaps Statement #2

Prof. A. Taleb-Bendiab, Product: Object-Oriented Encoding in C++, Code: CSP2104-5107, Lecture: 03, Date: 05/03/2013, Page: four

The Single-Alternative if #3

пЃ¬

Take note the difference between your following

пЃ¬

Example one particular:

Execute because

пЃ¬

Case 2:

Implement as

Prof. A. Taleb-Bendiab, Unit: Object-Oriented Programming in C++, Code: CSP2104-5107, Lecture: 03, Date: 05/03/2013, Webpage: 5

The Dual-Alternative in the event that

пЃ¬

if-else structure

пЃ¬

пЃ¬

пЃ¬

Syntax

in the event (Boolean expression)

action if true;

else action if false;

;

An else should always be associated with an in the event

You can obstruct multiple claims in the otherwise portion of a great if statement

Execute because

Prof. A. Taleb-Bendiab, Device: Object-Oriented Encoding in C++, Code: CSP2104-5107, Lecture: goal, Date: 05/03/2013, Page: six

Using a Nested if

пЃ¬

Nested if perhaps:

пЃ¬

in the event structure that rests totally within another if structure пЃ¬

inside either the if or perhaps the else terms



Also referred to as If-else-if

Prof. A. Taleb-Bendiab, Unit: Object-Oriented Programming in C++, Code: CSP2104-5107, Address: 03, Date: 05/03/2013, Web page: 7

Prevalent Pitfalls with if Statements

пЃ¬

пЃ¬

пЃ¬

пЃ¬

пЃ¬

пЃ¬

пЃ¬

Failing to remember that C++ comparisons will be case hypersensitive

Assuming that indentation has a rational purpose

Adding an unwanted semicolon

Negelecting curly orthodontic braces

Using = instead of ==

Making pointless comparisons

Creating unreachable code

See Figure 3-6

Prof. A. Taleb-Bendiab, Unit: Object-Oriented Programming in C++, Code: CSP2104-5107, Spiel: 03, Day: 05/03/2013, Page: 8

Forgetting that C++ Comparisons are Case Hypersensitive

пЃ¬

Code in Physique 3-10 displays " Unacceptable code” when a user

gets into ‘f'

Prof. A. Taleb-Bendiab, Unit: Object-Oriented Programming in C++, Code: CSP2104-5107, Spiel: 03, Date: 05/03/2013, Site: 9

Adding an Unwanted Semicolon

Be aware that

indentation does not have

logical purpose

Prof. A. Taleb-Bendiab, Product: Object-Oriented Coding in C++, Code: CSP2104-5107, Lecture: 03, Date: 05/03/2013, Page: twelve

Using sama dengan instead of ==

Prof. A. Taleb-Bendiab, Product: Object-Oriented Coding in C++, Code: CSP2104-5107, Lecture: goal, Date: 05/03/2013, Page: 11

Making Pointless Comparisons

Prof. A. Taleb-Bendiab, Unit: Object-Oriented Programming in C++, Code: CSP2104-5107, Address: 03, Particular date: 05/03/2013, Web page: 12

Producing Unnecessary Evaluations

Prof. A. Taleb-Bendiab, Device: Object-Oriented Programming in C++, Code: CSP2104-5107,...


Related

Internal Profits Essay

Energy Efficient Complexes Internal Warmth Gains and Design Heat & Air conditioning Loads Inner Heat Gains People and electrical equipment in buildings give off high temperature. These…...

An Assessment of Problem in the Purchase Profession in Government Essay

# 05 / 2010 TI Working Newspaper # 04/2010 Table of Contents 1 . Understanding data corruption in public procurement 2 . The cost…...

United Business Bank Dissertation

1 . Usa Commercial Financial institution is amongst the largest financial institutions that serve the Asian-American community inside the San Francisco region. The main focus is definitely on Chinese…...

Unit one particular Using ICT In Chilcare Studies Dissertation

п»їUnit 1: Employing ICT in Childcare Studies INTRODUCTION In this job I will be responding to questions define, based on the course supplies I have examine in Unit…...

Bond Concern Essay

Bond Issue The city of Salina, Kansas has been up against a tough decision. There are two high educational institutions in Salina. There is a university located southern…...

Parthenon Composition

Athena by Jerr Stowe Period 2 The god as the topic of discussion in this record is Athena. Athena was an important part of the Olympic…...

Milan Kundera’s The Unbearable Lightness of Being: Lightness or Heaviness Essay

п»їBrittany Stuberfield Professor Woehler Enc 1102 Nov 5, 2014 The Unbearable Lightness of Being The Unbearable Lightness of Being opens using a philosophical…...

science and indigenous knowledge Essay

" Scientific research: a human body of knowledge based on facts led by systematic experimentation, and analysis, plus the formulation of general principles” (Geddes and Grosset, 2007) vs .…...

Sample Approach Maps Dissertation

Sample Strategy Roadmaps Best Practice Strategy Maps Software Company Strategy Map Financial Perspective Leader in Strategic Market segments Increased Aktionar Value Mix up Revenue…...

Essay around the Merge: Tmobile and Metropcs

The Blend: T-Mobile & Metro COMPUTERS Two of the largest low-cost cellular providers, T-Mobile and Community PCS, happen to be preparing to combine into one solitary entity. The resulting…...