Conditional Statements

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 Decision Making Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E. Reingold.
Control Flow Statements: Repetition/Looping
Chapter 13 Control Structures. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display Control Structures Conditional.
The "if structure" is used to execute statement(s) only if the given condition is satisfied.
Week 6 - Programming I So far, we’ve looked at simple programming via “scripts” = programs of sequentially evaluated commands Today, extend features to:
© Janice Regan, CMPT 128, Jan CMPT 128: Introduction to Computing Science for Engineering Students Control Structures Nested ifs, switch statements.
Lecture 13 Decision structures
General Computer Science for Engineers CISC 106 Lecture 05 Dr. John Cavazos Computer and Information Sciences 2/20/2009.
Chapter 4 MATLAB Programming Logical Structures Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Programming with MATLAB. Relational Operators The arithmetic operators has precedence over relational operators.
Selection Programming EE 100. Outline introduction Relational and Logical Operators Flow Control Loops Update Processes.
ENG 1181 College of Engineering Engineering Education Innovation Center MAT – Conditional Statements Topics: 1.Conditional statements if-end if-else-end.
1. We’ve learned that our programs are read by the compiler in order, from top to bottom, just as they are written The order of statement execution is.
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand how decisions are made in a computer ❏ To understand the logical.
Logic Structures. If… else statements Meaning if the condition is true, execute this command. If the condition is false, execute the else command.
Computer Science: A Structured Programming Approach Using C1 5-2 Two-Way Selection The decision is described to the computer as a conditional statement.
General Computer Science for Engineers CISC 106 Lecture 2^4 Roger Craig Computer and Information Sciences 03/23/2009.
CSI 3125, Preliminaries, page 1 Control Statements.
The If Statement There are no switch statements in Python. You need to use just if statements. There are no switch statements in Python. You need to use.
Conditional statements and boolean expressions Arithmetic, relational and logical operators.
Conditional Statements A conditional statement lets us choose which statement will be executed next Conditional statements give us the power to make basic.
Silberschatz and Galvin  C Programming Language Decision making in C Kingdom of Saudi Arabia Ministry of Higher Education Al-Majma’ah University.
 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.
ITEC 2600 Introduction to Analytical Programming
1.3 ARITHMETIC OPERATIONS WITH SCALARS
Introduction to C++ Programming Language
C-Language Lecture By B.S.S.Tejesh, S.Neeraja
ECE 1304 Introduction to Electrical and Computer Engineering
Chapter 4 MATLAB Programming
Two-Dimensional Plots
Introduction to Programming for Mechanical Engineers (ME 319)
A computer program is a sequence of computer commands.
Control Structures.
Design via Frequency Response Techniques
IF if (condition) { Process… }
EGR 141 Computer Problem Solving in Engineering and Computer Science
محاضرة 1: مقدمة للمسـاق و مراجعـة للأساسيـات
Inverters Converting dc to ac
PULSE-WIDTH-MODULATED OUTPUT
Lab For the following simple switch mode power supply:
AMPLITUDE AND HARMONIC CONTROL
Inverters Converting dc to ac
Plotting Multiple Graphs In The Same Plot
Chapter2 Creating Arrays
Logical Operations In Matlab.
Visual Basic – Decision Statements
Selection Statements.
Conditional Logic Presentation Name Course Name
ARRAY DIVISION Identity matrix Islamic University of Gaza
Islamic University of Gaza
Comparison Functions Islamic University of Gaza Faculty of Engineering
Islamic University of Gaza
AC Voltage Controllers AC to ac Converters
THREE-PHASE INVERTERS
Understanding Conditions
Program Flow.
Using Script Files and Managing Data
Equalizing Average Source Power with Pattern Swapping
Chapter 3 Islamic University of Gaza Faculty of Engineering
Computer Programming Basics
Selection—Making Decisions
Histograms are plots that show the distribution of data.
USING ARRAYS IN MATLAB BUILT-IN MATH FUNCTIONS
Chapter 3: Selection Structures: Making Decisions
8.4 FOURIER SERIES ANALYSIS
Inverters Converting dc to ac
LABORATORY OF PROCESS ENGINEERING
ME 123 Computer Applications I Lecture 11: More on For loop 3/27/03
Input-Output Stability
Presentation transcript:

Conditional Statements Islamic University of Gaza Faculty of Engineering Civil Engineering Department Conditional Statements A conditional statement is a command that allows MATLAB to make a decision of whether to execute a group of commands that follow the conditional statement, or to skip these commands. In a conditional statement, a conditional expression is stated: If the expression is true, a group of commands that follow the statement are executed. If the expression is false, the computer skips the group. Computer Programming Computer Programming Dr.Moayed Almobaied CH6_2

Islamic University of Gaza Faculty of Engineering Civil Engineering Department Computer Programming Dr.Moayed Almobaied Computer Programming CH6_2

Islamic University of Gaza Faculty of Engineering Civil Engineering Department Computer Programming Dr.Moayed Almobaied Computer Programming CH6_2

The if- end Structure Islamic University of Gaza Faculty of Engineering Civil Engineering Department The if- end Structure Computer Programming Dr.Moayed Almobaied Computer Programming CH6_2

Islamic University of Gaza Faculty of Engineering Civil Engineering Department Computer Programming Dr.Moayed Almobaied Computer Programming CH6_2

Islamic University of Gaza Faculty of Engineering Civil Engineering Department Computer Programming Dr.Moayed Almobaied Computer Programming CH6_2

The if - else-end Structure Islamic University of Gaza Faculty of Engineering Civil Engineering Department The if - else-end Structure Computer Programming Dr.Moayed Almobaied Computer Programming CH6_2

The if -elseif -else-end Structure Islamic University of Gaza Faculty of Engineering Civil Engineering Department The if -elseif -else-end Structure Computer Programming Dr.Moayed Almobaied Computer Programming CH6_2

THE switch-case STATEMENT Islamic University of Gaza Faculty of Engineering Civil Engineering Department THE switch-case STATEMENT Computer Programming Dr.Moayed Almobaied Computer Programming CH6_2

Islamic University of Gaza Faculty of Engineering Civil Engineering Department Computer Programming Dr.Moayed Almobaied Computer Programming CH6_2

Computer Programming CH6_2

Islamic University of Gaza Faculty of Engineering Civil Engineering Department Computer Programming Dr.Moayed Almobaied Computer Programming CH6_2