Decision structure.
multiple alternative decision structure / case structure
A Loop.
Selection statement: if, switch/case, ternary conditional operator.
Transaction.
You use a nested if when the condition is dependent upon another condition. For example: if (ptr != nullptr) { // ptr is non-null -- test the value it refers to if (ptr* == 0) { // the value pointed to by ptr is zero } else { // the value pointed to by ptr is non-zero } } In this case, the alternative to a nested if creates an inefficiency: if (ptr != nullptr && *ptr == 0 ) { // ptr is valid and refers to the value zero } else if (ptr != nullptr) { // ptr is valid and refers to a non-zero value } In this example, the expression "ptr != nullptr" is evaluated twice when ptr is valid and refers to a non-zero value. The nested if only evaluates this expression one time.
Sequence structure, is a set of statements that execute in the order that they appear By evolutionx86
multiple alternative decision structure / case structure
A condition structure is a programming construct that allows you to execute certain code based on whether a specific condition is true or false. It typically involves the use of if-else statements to control the flow of the program based on different scenarios or conditions.
A Loop.
Selection statement: if, switch/case, ternary conditional operator.
Transaction.
ExecuteQuery() :To Execute SELECT StatementExecuteNonQuery() :To Execute Other Than Select Statements (INSERT/UPDATE/DELETE)
In while, from the very first term, every time, the related conditions in while will be checked and then the statements will execute. But, in do-while, all the statements under do will execute once and then compiler will check the while condition. Therefore, only first time only statements will execute without checking the conditions in while, but not from the second term repetition. written by DILSHAN MADUSANKA dilshanmadusanka@yahoo.com
You use a nested if when the condition is dependent upon another condition. For example: if (ptr != nullptr) { // ptr is non-null -- test the value it refers to if (ptr* == 0) { // the value pointed to by ptr is zero } else { // the value pointed to by ptr is non-zero } } In this case, the alternative to a nested if creates an inefficiency: if (ptr != nullptr && *ptr == 0 ) { // ptr is valid and refers to the value zero } else if (ptr != nullptr) { // ptr is valid and refers to a non-zero value } In this example, the expression "ptr != nullptr" is evaluated twice when ptr is valid and refers to a non-zero value. The nested if only evaluates this expression one time.
default : <statement>; i.e. switch (value) { case 1 : do_this(); break; case 2 : do_that(); break; default : do_whatever(); }
An alternative decision structure in programming is typically implemented using the "switch" statement or "case" structure. This structure allows for multiple possible execution paths based on the value of a variable, enabling the program to execute different blocks of code depending on specific cases. It provides a more organized way to handle multiple conditions compared to using multiple "if-else" statements.
Statements that check an expression then may or may not execute a statement or group of statements depending on the result of the condition.