Topics discussed in this section:

Slides:



Advertisements
Similar presentations
Topics discussed in this section:
Advertisements

Computer Science: A Structured Programming Approach Using C Converting File Type A rather common but somewhat trivial problem is to convert a text.
CS2422 Assembly Language and System Programming Linking Loader Department of Computer Science National Tsing Hua University.
true (any other value but zero) false (zero) expression Statement 2
Tutorial 4 Decision Making with Control Structures and Statements Section A - Decision Making JavaScript Tutorial 4 -Decision Making with Control.
C++ for Engineers and Scientists Third Edition
Visual C++ Programming: Concepts and Projects
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 9 – Income Tax Calculator Application: Introducing.
C How to Program, 6/e Summary © by Pearson Education, Inc. All Rights Reserved.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand design concepts for fixed-length and variable- length strings ❏
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Structural Program Development: If, If-Else Outline.
1 Chapter 4: Selection Structures. In this chapter, you will learn about: – Selection criteria – The if-else statement – Nested if statements – The switch.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To be able to list and describe the six expression categories ❏ To understand.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand how decisions are made in a computer ❏ To understand the logical.
Control Structures 1. Control Structures Java Programming: From Problem Analysis to Program Design, D.S. Malik 2.
Computer Science: A Structured Programming Approach Using C1 5-3 Multiway Selection In addition to two-way selection, most programming languages provide.
1 Objectives ❏ To understand how decisions are made in a computer ❏ To understand the logical operators: and, or, and not ❏ To understand how a C program.
Dale Roberts 1 Program Control - Algorithms Department of Computer and Information Science, School of Science, IUPUI CSCI N305.
Refer to Ivor Horton’s Beginning ANSI C++ The Complete Language, 3rd Ed. APress Media, LLC. Choices and Decisions if statement if-else statement Relational.
Computer Science: A Structured Programming Approach Using C1 5-2 Two-Way Selection The decision is described to the computer as a conditional statement.
Computer Science: A Structured Programming Approach Using C1 5-2 Two-Way Selection The decision is described to the computer as a conditional statement.
Computer Science: A Structured Programming Approach Using C1 2-7 Input/Output Although our programs have implicitly shown how to print messages, we have.
1 CS161 Introduction to Computer Science Topic #8.
CONTROL STRUCTURE. 2 CHAPTER OBJECTIVES  Learn about control structures.  Examine relational and logical operators.  Explore how to form and evaluate.
Computer Science: A Structured Programming Approach Using C1 5-5 Incremental Development Part II In Chapter 4, we introduced the concept of incremental.
Program Control: Selection Subject: T0016 – ALGORITHM AND PROGRAMMING Year: 2013.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand how decisions are made in a computer ❏ To understand the logical.
C++ for Engineers and Scientists Second Edition Chapter 4 Selection Structures.
Chapter 4: Control Structures I (Selection). Objectives In this chapter, you will: – Learn about control structures – Examine relational operators – Discover.
CNG 140 C Programming (Lecture set 3)
More on the Selection Structure
Topics discussed in this section:
Statements (6 of 6) A statement causes an action to be performed by the program. It translates directly into one or more executable computer instructions.
Selection—Making Decisions
Test Review Computer Science History
Flow of Control.
The Selection Structure
DKT121: Fundamental of Computer Programming
Programming Fundamentals
Topics discussed in this section:
Topics discussed in this section:
Topics discussed in this section:
Chapter 4: Control Structures I (Selection)
الكلية الجامعية للعلوم التطبيقية
Decision Making.
And now for something completely different . . .
IF if (condition) { Process… }
Introduction to Programming
3-3 Side Effects A side effect is an action that results from the evaluation of an expression. For example, in an assignment, C first evaluates the expression.
Regular Grammar.
Unit 1: Introduction Lesson 1: PArts of a java program
3-3 Side Effects A side effect is an action that results from the evaluation of an expression. For example, in an assignment, C first evaluates the expression.
Topics discussed in this section:
Topics discussed in this section:
Topics discussed in this section:
Chapter 4: Control Structures I (Selection)
Topics discussed in this section:
Control Structure Chapter 3.
Week 3 – Program Control Structure
Topics discussed in this section:
CHAPTER 4: Conditional Structures
Section 3.7 Switching Circuits
Selection—Making Decisions
Topics discussed in this section:
CS150 Introduction to Computer Science 1
Topics discussed in this section:
Control Structure.
Flow of Control Flow of control is the order in which a program performs actions. Up to this point, the order has been sequential. A branching statement.
Topics discussed in this section:
Structural Program Development: If, If-Else
Presentation transcript:

Topics discussed in this section: 5-3 Multiway Selection In addition to two-way selection, most programming languages provide another selection concept known as multiway selection. Multiway selection chooses among several alternatives. C has two different ways to implement multiway selection: the switch statement and else-if construct. Topics discussed in this section: The switch Statement The else-if Computer Science: A Structured Programming Approach Using C

FIGURE 5-19 switch Decision Logic Computer Science: A Structured Programming Approach Using C

FIGURE 5-20 switch Statement Syntax Computer Science: A Structured Programming Approach Using C

FIGURE 5-21 switch Flow Computer Science: A Structured Programming Approach Using C

Demonstrate the switch Statement PROGRAM 5-6 Demonstrate the switch Statement Computer Science: A Structured Programming Approach Using C

FIGURE 5-22 switch Results Computer Science: A Structured Programming Approach Using C

FIGURE 5-23 A switch with break Statements Computer Science: A Structured Programming Approach Using C

Multivalued case Statements PROGRAM 5-7 Multivalued case Statements Computer Science: A Structured Programming Approach Using C

Summary of switch Statement Rules Table 5-5 Summary of switch Statement Rules Computer Science: A Structured Programming Approach Using C

PROGRAM 5-8 Student Grading Computer Science: A Structured Programming Approach Using C

PROGRAM 5-8 Student Grading Computer Science: A Structured Programming Approach Using C

PROGRAM 5-8 Student Grading Computer Science: A Structured Programming Approach Using C

FIGURE 5-24 The else-if Logic Design for Program 5-9 Computer Science: A Structured Programming Approach Using C

Note The else-if is an artificial C construct that is only used when 1. The selection variable is not an integral, and 2. The same variable is being tested in the expressions. Computer Science: A Structured Programming Approach Using C

PROGRAM 5-9 Convert Score to Grade Computer Science: A Structured Programming Approach Using C

PROGRAM 5-9 Convert Score to Grade Computer Science: A Structured Programming Approach Using C

PROGRAM 5-9 Convert Score to Grade Computer Science: A Structured Programming Approach Using C

Topics discussed in this section: 5-4 More Standard Functions One of the assets of the C language is its rich set of standard functions that make programming much easier. For example, C99 has two parallel but separate header files for manipulating characters: ctype.h and wctype.h. Topics discussed in this section: Standard Characters Functions A Classification Program Handling Major Errors Computer Science: A Structured Programming Approach Using C

FIGURE 5-25 Classifications of the Character Type Computer Science: A Structured Programming Approach Using C

Classifying Functions continued Table 5-6 Classifying Functions Computer Science: A Structured Programming Approach Using C

Classifying Functions (continued) Table 5-6 Classifying Functions (continued) Computer Science: A Structured Programming Approach Using C

Table 5-7 Conversion Functions Computer Science: A Structured Programming Approach Using C

Demonstrate Classification Functions PROGRAM 5-10 Demonstrate Classification Functions Computer Science: A Structured Programming Approach Using C

Demonstrate Classification Functions PROGRAM 5-10 Demonstrate Classification Functions Computer Science: A Structured Programming Approach Using C