IF if (condition) { Process… }

Slides:



Advertisements
Similar presentations
Java Control Statements
Advertisements

IF statement (i) Single statement. IF ( logical expression ) statement Example: read(*,*) a if (a. lt. 0) a = -a write(*,*) a Or read(*,*) a if (a < 0)
Decision Making EE2372 Software Design I Dr. Gerardo Rosiles.
1 Chapter Five Selection and Repetition. 2 Objectives How to make decisions using the if statement How to make decisions using the if-else statement How.
© Janice Regan, CMPT 128, Jan CMPT 128: Introduction to Computing Science for Engineering Students Control Structures Nested ifs, switch statements.
Chapter 4 Control Structures I. Objectives ► Examine relational and logical operators ► Explore how to form and evaluate logical (Boolean) expressions.
Selection Statements choice of one among several blocks of code Java supports 3 kinds of selection statements: if statement – selects one block or leaves.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming Logical and Relational Expressions Nested if statements.
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
 Decision making statements Decision making statements if statement if...else statement Nested if...else statement (if...elseif....else Statement) 
Conditional Statements While writing a program, there may be a situation when you need to adopt one path out of the given two paths. So you need to make.
Chapter 4: Decision Making with Control Structures and Statements JavaScript - Introductory.
5-1 Repetition Statements Repetition statements allow us to execute a statement multiple times Often they are referred to as loops Like conditional statements,
Logic Structures. If… else statements Meaning if the condition is true, execute this command. If the condition is false, execute the else command.
ㅎㅎ logical operator if if else switch while do while for Third step for Learning C++ Programming Repetition Control Structures.
Conditional Statement Chapter 8. Conditional Statements Are statements that check an expression then may or may not execute a statement or group of statement.
Decision making statements. Decision making statements are used to skip or to execute a group of statements based on the result of some condition. The.
1 2. Program Construction in Java. 2.4 Selection (decisions)
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 ‏ Control Structures.
Conditional Structures UNIVERSITY OF THE PUNJAB (GUJRANWALA CAMPUS) ADNAN BABAR MT14028 CR
Lecture 2 Control Structure. Relational Operators -- From the previous lecture Relational Operator Meaning == is equal to < is less than > is greater.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.1.
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
© M. Gross, ETH Zürich, 2014 Informatik I für D-MAVT (FS 2014) Exercise 4 – Logical Operators & Branching.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.1.
 Control Flow statements ◦ Selection statements ◦ Iteration statements ◦ Jump statements.
1 1 Additional Control Structures Chapter 9 2 New and Improved... Ways to branch Ways to write loops Understanding the break and continue statements.
Control Flow Statements
CSI 3125, Preliminaries, page 1 Control Statements.
Decision Statements, Short- Circuit Evaluation, Errors.
Mindstorm NXT-G Introduction Towson University Robotics.
Programming Language C++ Lecture 3. Control Structures  C++ provides control structures that serve to specify what has to be done to perform our program.
STRUCTURED PROGRAMMING Selection Statements. Content 2  Control structures  Types of selection statements  if single-selection statement  if..else.
Chapter 7 Control Structures. Java has very flexible three looping mechanisms. You can use one of the following three loops:  while Loop  do...while.
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.
 By the end of this section you should be able to: ◦ Differentiate between sequence, selection, and repetition structure. ◦ Differentiae between single,
LECTURE # 7 : STRUCTURED PROGRAMMING Selection Statements Tr.Hadeel.
 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.
Loops causes program to execute the certain block of code repeatedly until some conditions are satisfied. Suppose you want to execute some code/s 10 times.
Branching statements.
Java Programming Fifth Edition
Chapter 3: Decisions and Loops
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.
Programming Fundamentals
Ch 7: JavaScript Control Statements I.
Programming Fundamentals
JavaScript: Control Statements.
JavaScript: Control Statements I
Control Structures.
Microsoft Visual Basic 2005 BASICS
Loop Control Structure.
الكلية الجامعية للعلوم التطبيقية
Control Structures: Selection Statement
ICT Programming Lesson 3:
Lecture Notes – Week 2 Lecture-2
Conditionals.
Program Flow.
PROGRAM FLOWCHART Selection Statements.
There many situations comes in real life when we need to make some decisions and based on these decisions, we decide what should we do next. Similar situations.
Decisions, decisions, decisions
Control Structures: Selection Statement
Decision making and control functions
statement. Another decision statement, , creates branches for multi-
PHP CONDITIONAL STATEMENTS
Lesson 3. Controlling program flow. Loops. Methods. Arrays.
break & continue Statements
Presentation transcript:

IF if (condition) { Process… } . IF if (condition) { Process… } The if statement checks whether the text expression inside parenthesis () is true or not. If the test expression is true, statement/s inside the body of if statement is executed but if test is false, statement/s inside body of if is ignored…

IF-ELSE if (condition) { Process… } else The if...else statement is used if the programmer wants to execute some statement/s when the test expression is true and execute some other statement/s if the test expression is false.

IF,ELSE IF AND ELSE if (condition) { Process… } else if(condition) if… else if … else if …… else statement is used when program requires more than one test expression.

Switch Case switch(variable) { case value1: process; break; case value2: process; break; . case valueN: process; break; default: process; break; } Decision making are needed when, the program encounters the situation to choose a particular statement among many statements. If a programmer has to choose one block of statement among many alternatives, if… else if … else if …… else can be used but, this makes programming logic complex. This type of problem can be handled in C programming using switch statement.

In C programming, break; is used in terminating the loop immediately after it is encountered. The break statement is used with conditional if statement.