Conditional Statements. Program control statements modify the order of statement execution. Statements in a C program normally executes from top to bottom,

Презентация:



Advertisements
Похожие презентации
Aim The experiment is aimed at testing the following hypothesis: light is necessary for the leaves of a young plant to become green.
Advertisements

Operators and Arithmetic Operations. Operators An operator is a symbol that instructs the code to perform some operations or actions on one or more operands.
© 2005 Cisco Systems, Inc. All rights reserved. BGP v Route Selection Using Policy Controls Applying Route-Maps as BGP Filters.
Blood type Blood type or blood group is a medical term. It describes the type of blood a person has. This blood type is based on whether or not there are.
Ways to Check for Divisibility Vüsal Abbasov Dividing By 1 All numbers are divisible by 1.
How to write a story First you have to….. Decide who the characters are. Who is going to be in the story? What sort of characters are they?
Verilog - Operator, operand, expression and control - Ando KI Spring 2009.
Date: File:GRAPH_02e.1 SIMATIC S7 Siemens AG All rights reserved. SITRAIN Training for Automation and Drives Project Planning and Configuration.
Inner Classes. 2 Simple Uses of Inner Classes Inner classes are classes defined within other classes The class that includes the inner class is called.
Safety and seamanship n n ALPHA SHIP is an internationally ас- claimed shipping company with а fleet of 20 highly sophisticated full container ships that.
TENSE AND TIME A tense is an inflectional (флективная) form of a verb expressing a specific time distinction. Time is a measurable period during which.
LET US LEARN and PRACTICE! Conditional 0 If +Present Simple, Present simple Real actions -100% Situations that are always true if something happens.
Verilog - Behavioral Modeling - Ando KI Spring 2009.
Loader Design Options Linkage Editors Dynamic Linking Bootstrap Loaders.
A Bill is a proposal for a new law, or a proposal to change an existing law that is presented for debate before Parliament. Bills are introduced in either.
Benford Benford's law, also called the first-digit law, states that in lists of numbers from many (but not all) real-life sources of data, the leading.
While its always a good idea to think outside the box when approaching a creative task, this is not always the case. For example, when working with teams,
BUSINESS LETTER TRUE OR FALSE TEST. Are the following statements True or False? TRUE FALSE.
The problem of String Matching Given a string S, the problem of string matching deals with finding whether a pattern p occurs in S and if p does occur.
Our parents it is all in our life. They know more us, they us learn us how correctly to live that is possible, and that isn't present.
Транксрипт:

Conditional Statements

Program control statements modify the order of statement execution. Statements in a C program normally executes from top to bottom, in the order that they appear in the source code. These control statements decide whether to perform a particular block of statements. These control statements decide whether to perform a particular block of statements.

The if statement if (condition) { statements; } If expression evaluates to true, the block of statements are executed, if false then the block of statements are not executed. In either case, execution then passes to whatever code follows the if statement.

The if-else statement if (condition) { statement1; } else { statement2; } If the conditional expression evaluates to true, statement1 is executed, if false then statement2 is executed

The if else if statement if (condition) { statement1; } else if (condition) { statement2; } else if (condition) { statement3; } else { statement4; }

If the first conditional expression evaluates to true, the statement 1 shall be executed, however if it is not true then the next conditional expression shall be tested for statement 2 to be executed and so on. If no conditional expression has been satisfied, then the statement after the last else shall be executed

The switch statement switch(variable) { case constant1: statement; break; case constant2: statement; break; default: statement; }

When a match is found, the statements associated with that case are executed until a break is reached. A break will cause immediate termination from the body of the switch. If there is no match with the variable and the cases, the default statement shall be executed. The default is optional and if it is not present, no action takes place if all matched fail.