Decisions in C
Decision or Branching in C or C++
In programming, decision or branching refers to the process of controlling the flow of a program by making choices based on certain conditions. A condition is evaluated either to true or false. A program is a set of instructions executed in sequence; the decision statement changes the sequence of the execution. It involves the use of conditional statements to determine which block of code should be executed next. Decision-making is a basic concept in programming. It is essential for creating dynamic and responsive applications.
Think, how login functionality is implemented. A decision to login is made on condition whether entered username and password is correct or not.
if (condition) {
// Code to execute if condition is true
}
else {
//Code to execute if condition is false
}
No comments: