Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand how decisions are made in a computer ❏ To understand the logical.

Slides:



Advertisements
Similar presentations
Decision Structures - If / Else If / Else. Decisions Often we need to make decisions based on information that we receive. Often we need to make decisions.
Advertisements

Chapter 4: Control Structures I (Selection)
Chapter 13 Control Structures. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display Control Structures Conditional.
Control Structures Control structures are used to manage the order in which statements in computer programs will be executed Three different approaches.
Objectives AND logic OR logic Evaluating compound conditions with multiple logical operators Precedence when combining AND and OR operators Efficiency.
An Introduction to Programming with C++ Fifth Edition Chapter 5 The Selection Structure.
Decisions (Conditional Programming) Chapter 5 (Sec. 5.1 & 5.2)
Class 9.1 Chapter 4 Sections: 4.1, 4.2, 4.3
16/27/ :53 PM6/27/ :53 PM6/27/ :53 PMLogic Control Structures Arithmetic Expressions Used to do arithmetic. Operations consist of +,
Chapter 4: Control Structures: Selection
1 Statement-Level Control Structures Levels of flow control Control Statements 1. Sequence 2. Selection 3. Iteration Unconditional branching Guarded commands.
Computer Science 101 The Boolean System. George Boole British mathematician ( ) Boolean algebra –Logic –Set theory –Circuits –Conditions in if.
Apply Properties of Rational Exponents
Chapter 4: Control Structures I
CPS120: Introduction to Computer Science Decision Making in Programs.
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.
Copyright 2013, 2010, 2007, Pearson, Education, Inc. Section 3.7 Switching Circuits.
Practice 1.2 Answers
Computer Science 111 Fundamentals of Programming I Making Choices with if Statements.
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.
Lesson - 5. Introduction While programming, we usually need to decide the path of the program flow according to the parameters and conditions. Actually.
1 © 2002 John Urrutia. All rights reserved. Qbasic Chapter 4 IF Statements and READ & DATA.
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.
IB Computer Science – Logic
Selection-making Decisions Selection allows you to choose between two or more possible program flow --- it lets you make decisions in your program. Examples.
Programming Perl in UNIX Course Number : CIT 370 Week 3 Prof. Daniel Chen.
Computer Programming TCP1224 Chapter 5 The Selection Structure.
Exponent Quiz Review. Evaluate the expression 4 2  Answer: 16.
8. DECISION STRUCTURES Rocky K. C. Chang October 18, 2015 (Adapted from John Zelle’s slides)
1 CS161 Introduction to Computer Science Topic #6.
1.4 Properties of Real Numbers ( )
CPS120: Introduction to Computer Science Decision Making in Programs.
Computer Science: A Structured Programming Approach Using C1 5-5 Incremental Development Part II In Chapter 4, we introduced the concept of incremental.
1-1 © 2008 Pearson Prentice Hall. All rights reserved Chapter 1 Real Numbers and Algebraic Expressions Active Learning Questions.
Logical Expressions ENGR 1181 MATLAB 6. Logical Expressions in Real Life Sorting objects in manufacturing processes can be accomplished automatically.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand how decisions are made in a computer ❏ To understand the logical.
Random Functions Selection Structure Comparison Operators Logical Operator
 Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do.
Computer Science 210 Computer Organization
AND.
Sequence, Selection, Iteration The IF Statement
Introduction to C++ Programming Language
Section 7.1 Logical Operators
Decisions Chapter 4.
Selection—Making Decisions
Basic Logical Operations (Fascinating)
SECTION 1-2 : ORDER OF OPERATIONS and EVALUATING EXPRESSIONS
Chapter 6 Repetition Objectives ❏ To understand basic loop concepts:
Topics discussed in this section:
Topics discussed in this section:
Chapter 14 Bitwise Operators Objectives
Types, Truth, and Expressions (Part 2)
Computer Science 210 Computer Organization
Topics discussed in this section:
Conditional Statements
Conditional Logic Presentation Name Course Name
Types, Truth, and Expressions (Part 2)
4105 CHALLENGING REVIEW QUIZ
4-2 Functions in C In C, the idea of top–down design is done using functions. A C program is made of one or more functions, one and only one of which.
Topics discussed in this section:
Section 3.7 Switching Circuits
Computer Programming Basics
Selection—Making Decisions
Topics discussed in this section:
Chapter 3: Selection Structures: Making Decisions
2-2 Logic Part 2 Truth Tables.
Presentation transcript:

Computer Science: A Structured Programming Approach Using C1 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 evaluates a logical expression ❏ To write programs using logical and comparative operators ❏ To write programs that use two-way selection: if... else statements ❏ To write programs that use multi-way selection: switch and else...if ❏ To understand C’s classification of characters ❏ To write programs that use C’s character functions ❏ To be able to design a structure chart that specifies function selection Chapter 5 Chapter 5 Selection—Making Decisions Selection—Making Decisions

Computer Science: A Structured Programming Approach Using C2 5-1 Logical Data and Operators A piece of data is called logical if it conveys the idea of true or false. In real life, logical data (true or false) are created in answer to a question that needs a yes– no answer. In computer science, we do not use yes or no, we use true or false. Logical Data in C Logical Operators Evaluating Logical Expressions Comparative Operators Topics discussed in this section:

Computer Science: A Structured Programming Approach Using C3 FIGURE 5-1 true and false on the Arithmetic Scale

Computer Science: A Structured Programming Approach Using C4 FIGURE 5-2 Logical Operators Truth Table

Computer Science: A Structured Programming Approach Using C5 FIGURE 5-3 Short-circuit Methods for and /or

Computer Science: A Structured Programming Approach Using C6 PROGRAM 5-1Logical Expressions

Computer Science: A Structured Programming Approach Using C7 PROGRAM 5-1Logical Expressions

Computer Science: A Structured Programming Approach Using C8 FIGURE 5-4 Relational Operators

Computer Science: A Structured Programming Approach Using C9 FIGURE 5-5 Comparative Operator Complements

Computer Science: A Structured Programming Approach Using C10 Table 5-1Examples of Simplifying Operator Complements

Computer Science: A Structured Programming Approach Using C11 PROGRAM 5-2Comparative Operators

Computer Science: A Structured Programming Approach Using C12 PROGRAM 5-2Comparative Operators