Computer Science Department FTSM Control Structure: Selection (Part 1) Knowledge: Understand various concepts of selection control structure Skill: Be.

Slides:



Advertisements
Similar presentations
ALGORITHMS AND FLOWCHARTS
Advertisements

Sorting algorithms Sieve of Eratosthenes
Computer Programming Mr. José A. Ortiz Morris. Computer Language  Languages that the computer understands.  They are low level languages. (BINARY 1.
ALGORITHMS AND FLOWCHARTS
PROBLEM SOLVING TECHNIQUES
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 4 Making Decisions in a Program.
Subject: Information Technology Grade: 10
ALGORITHMS AND FLOWCHARTS
Computer Science Department FTSM Control Structure: Selection (Part 2) Knowledge: Understand various concepts of selection control structure Skill: Be.
Chapter 2 Review Questions
1 CSC103: Introduction to Computer and Programming Lecture No 8.
Computer Science Department FTSM Variables and Constants Knowledge: Understand the concept of storage location representation as identifiers Skill: Identify.
Flow Charting, Structured English and PseudoCode
LOOP (Part 2) for while do-while 1. TK1913-C Programming2 TK1913-C Programming 2 Loop : for Loop : for Condition is tested first Loop is controlled by.
Chapter 4 Control Structure: Loop Knowledge: Understand the various concepts of loop control structure Skill: Be able to develop a program involving loop.
Developing logic (Examples on algorithm and flowchart)
Programming with MATLAB. Relational Operators The arithmetic operators has precedence over relational operators.
Operators and Expressions
ALGORITHMS AND FLOWCHARTS
Lecture Set 5 Control Structures Part A - Decisions Structures.
CSEB114: Principle of programming
End Show Writing a computer program involves performing the following tasks. 1. Understanding the problem 2. Developing an Algorithm for the problem 3.
Conditions. Objectives  Understanding what altering the flow of control does on programs and being able to apply thee to design code  Look at why indentation.
Selection Control Structure. Topics Review sequence control structure Structure theorem Selection control structure If statement Relational operators.
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand how decisions are made in a computer ❏ To understand the logical.
ALGORITHMS AND FLOWCHARTS CSCI 105 – Computer Fluency.
Lecture 3 – Selection. Outline Recall selection control structure Types of selection One-way selection Two-way selection Multi-selection Compound statement.
The IF-statements 31-Jan-2005 Venkatesh Ramamoorthy.
Conditional Statements.  Quiz  Hand in your jQuery exercises from last lecture  They don't have to be 100% perfect to get full credit  They do have.
Fundamentals of Algorithms MCS - 2 Lecture # 5. Representation of Algorithms (continued) Flowcharts.
Chapter 3 Decisions Three control structures Algorithms Pseudocode Flowcharts If…then …else Nested if statements Code blocks { } multi statement blocks.
110 F-1 Decisions and Conditions Chapter 4: We can design a form We can calculate To make our programs more powerful, we need to be able to make choices.
Fundamental Programming Fundamental Programming More Expressions and Data Types.
Concepts of Algorithms CSC-244 Unit Zero Pseudo code, Flowchart and Algorithm Master Prince Computer College Qassim University K.S.A.
Topics: Selection Statements. Processing Involving Selecting Instructions An instruction that allows deviation and selection to take place uses the ‘IF’
The Department of Engineering Science The University of Auckland Welcome to ENGGEN 131 Engineering Computation and Software Development Lecture 2 Debugging,
If statement.  It is made up of three main components:  The keyword itself,  an expression that is tested for its truth value,  and a code suite to.
Computer Science 1000 Algorithms III. Multiple Inputs suppose I ask you to write a program that computes the area of a rectangle area = length * width.
Learning Objective To be able to… Understand flow chart symbols Complete and correct flow chart algorithms Create a program based on a flow chart.
ALGORITHMS AND FLOWCHARTS. A typical programming task can be divided into two phases: Problem solving phase  produce an ordered sequence of steps that.
Introduction to Programming Python Lab 7: if Statement 19 February PythonLab7 lecture slides.ppt Ping Brennan
CSE202: Lecture 5The Ohio State University1 Selection Structures.
1 VB-04-Control Structures 16 March 2016 Visual Basic Control Structures - Selection.
Lecture 2: Introduction to Programming EEE2108: 공학프로그래밍 서강대학교 전자공학과 2011 학년도 2 학기 - Algorithms and Flowcharts -
Selection Using IF THEN ELSE CASE Introducing Loops.
SELECTION CONTROL STRUCTURE Prepared by: Careene McCallum-Rodney.
GC101 Introduction to computers and programs
Selection Control Structure
COVERED BASICS ABOUT ALGORITHMS AND FLOWCHARTS
Algorithms and Flowcharts
Chapter 5: Control Structure
9 x 14 9 x 12 Calculate the value of the following: 1 4 × 5 =
ALGORITHMS & FLOWCHARTING II
COMS W1004 Introduction to Computer Science and Programming in Java
ALGORITHMS AND FLOWCHARTS
Factors, multiple, primes: Factors from prime factors
ALGORITHMS AND FLOWCHARTS
ALGORITHM BASICS- Part 3
Control Structure Senior Lecturer
ALGORITHMS AND FLOWCHARTS
Factors, multiple, primes: Prime factors
Chapter 5: Control Structure
Control Structure: Selection (Part 2)
Introduction to Programming
Programming Concepts and Database
Selection Structures: Single-alternative
Chapter 3: Selection Structures: Making Decisions
Factors, multiple, primes: Multiples
Presentation transcript:

Computer Science Department FTSM Control Structure: Selection (Part 1) Knowledge: Understand various concepts of selection control structure Skill: Be able to develop a program containing selection control structure

TK1913-C Programming2 TK1913-C Programming 2 Selection Structure Single Selection Double Selection Multiple Selection

TK1913-C Programming3 TK1913-C Programming 3 Single Selection Pseudocode Structure step a if start step m step n end_if step x Pseudocode Structure step a if start step m step n end_if step x

TK1913-C Programming4 TK1913-C Programming 4 Single Selection Step a condition Step m Step n Step x true false Step a condition Step m Step n Step x true false

TK1913-C Programming5 TK1913-C Programming 5 Exercise Develop an algorithm for the following problem: A system to check/verify the eligibility of a person to vote during the election is going to be developed. The input for the system is the person’s age. If the age is greater than 20 years old, then display “You are eligible to vote” and “Your age is years old” messages. If the age is less than 20 years old, display “Your age is years old” message only.

TK1913-C Programming6 TK1913-C Programming 6 Exercise - Answer true false “You are eligible to vote” agestartend “Your age is years old” age > 20 truefalse “You are eligible to vote” age start end “Your age is years old” age > 20 Assume the age is 12 years old 12 > 20 ? FALSE ! Your age is 12 years old

TK1913-C Programming7 TK1913-C Programming 7 Something to ponder … the age is 37 years old? What if ….. What about 20 years old?

TK1913-C Programming8 TK1913-C Programming 8 Let’s recap … Pseudocode Structure step a if start step m step n end_if step x Pseudocode Structure step a if start step m step n end_if step x Single Selection Double selection has similar structure except that …

TK1913-C Programming9 TK1913-C Programming 9 Double Selection Pseudocode Structure step a if start step m step n end_if else start step x step y end_else step z Pseudocode Structure step a if start step m step n end_if else start step x step y end_else step z … additional steps at the bottom …

TK1913-C Programming10 TK1913-C Programming 10 Double Selection Step a condition Step m Step n Step z true false Step x Step y Step a condition Step m Step n Step z true false Step x Step y

TK1913-C Programming11 TK1913-C Programming 11 Exercise Develop an algorithm for the following problem: A system to check/verify the eligibility of a person to vote during the election is going to be developed. The input for the system is the person’s age. If the age is greater than 20 years old, then display “You are eligible to vote” and “Your age is years old” messages. If the age is less than 20 years old, display “You are not eligible to vote” and “Your age is years old” messages.

TK1913-C Programming12 TK1913-C Programming 12 Exercise - Answer true false “You are eligible to vote” age start end “Your age is years old” age > 20 Verify this flowchart ! “You are not eligible to vote”

TK1913-C Programming13 TK1913-C Programming 13 Let’s recap … Pseudocode Structure step a if start step m step n end_if step x Pseudocode Structure step a if start step m step n end_if step x Single Selection Pseudocode Structure step a if start step m step n end_if else start step x step y end_else step z Pseudocode Structure step a if start step m step n end_if else start step x step y end_else step z Double Selection Guess…how does multiple selection look like ?

TK1913-C Programming14 TK1913-C Programming 14 Multiple Selection Pseudocode Structure (Multi-way if) step a if start step m end_if if start step n end_if step z Pseudocode Structure (Multi-way if) step a if start step m end_if if start step n end_if step z

TK1913-C Programming15 TK1913-C Programming 15 Multiple Selection Step a Condition1 Step m Step n Step z true false Condition2 true false Step a Condition1 Step m Step n Step z true false Condition2 true false

TK1913-C Programming16 TK1913-C Programming 16 Multiple Selection Pseudocode Structure (Cascaded if) step a if start step m end_if if start step n end_if else start step x end_else step z Pseudocode Structure (Cascaded if) step a if start step m end_if if start step n end_if else start step x end_else step z

TK1913-C Programming17 TK1913-C Programming 17 Multiple Selection Step a Condition1 Step m Step n Step z true false Condition2 true false Step x Step a Condition1 Step m Step n Step z true false Condition2 true false Step x

TK1913-C Programming18 TK1913-C Programming 18 Exercise Develop a flowchart for the following problem. Given a mark, determine its grade based on the table below: 74 < mark < 100grade = A 64 < mark < 75grade = B 54 < mark < 65grade = C 39 < mark < 55grade = D 0 < mark < 40grade = E others error message

TK1913-C Programming19 TK1913-C Programming 19 End of Lecture 7 (Part 1) Yes !! That’s all? What’s next??? PART 2 on the way… relax !