Скачать презентацию Decision structure in C Let there are Скачать презентацию Decision structure in C Let there are

Research work.pptx

  • Количество слайдов: 7

Decision structure in C++ Decision structure in C++

Let there are multiple statements in the code. This program provides an ability to Let there are multiple statements in the code. This program provides an ability to the programmer to decide what statements to be executed and what statements should not be executed depending upon the specific condition. This is known as decision making

Decision-making is an important concept in any programming language and to accomplish this, C++ Decision-making is an important concept in any programming language and to accomplish this, C++ uses the following decision making statements: If statement if statement If. . . else statement if. . else statement Switch statement switch statement Conditional operator conditional operator Decision making statements

IF statement if statement allows us to control a program whether to execute specific IF statement if statement allows us to control a program whether to execute specific statement or not. If statement is used to complete an operation, if a condition is true Condition can be true or false The condition will be checked and if it is true then the statement will be executed.

IF…ELSE statement The if. . . else executes body of if when the condition IF…ELSE statement The if. . . else executes body of if when the condition is true and executes the body of else if condition is false.

SWITCH statement. Allows selection among multiple sections of code, depending on the value of SWITCH statement. Allows selection among multiple sections of code, depending on the value of an integral expression. A switch statement includes one or more switch sections. Each switch section contains one or more case labels followed by one or more statements.

 Сonditional operator (? : ) The conditional operator (? : ) is a Сonditional operator (? : ) The conditional operator (? : ) is a ternary operator (it takes three operands). The first operand is implicitly converted to bool. It is evaluated and all side effects are completed before continuing. If the first operand evaluates to true (1), the second operand is evaluated. If the first operand evaluates to false (0), the third operand is evaluated. The result of the conditional operator is the result of whichever operand is evaluated — the second or the third. Only one of the last two operands is evaluated in a conditional expression.