C Programming Language
--Decision Control Branching Statements—
Day 04
Join us in telegram- click here
Decision control Branching statements
> If Statement: An "if" statement is used to make a decision in programming.
It checks if a certain condition is true, and if it is, then it executes a specific
block of code.
Syntax:
if (condition)
{
# Code to execute if condition is true
}
Decision control Branching statements
>If-Else Statement: An "if-else" statement is an extension of the "if“ statement.
If the condition in the "if" part is true, it runs one block of code; if the
condition is false, it runs another block of code in the "else" part.
Syntax:
if (condition)
{
// Code to execute if condition is true
}
else
{
// Code to execute if condition is false
}
Decision control Branching statements
>Else-If Statement: An "else-if" statement allows you to check multiple
conditions in sequence. If the condition in the initial "if" statement is false, the
program checks subsequent "else-if" conditions until it finds a true one or
reaches the "else" part.
Syntax: if (condition1)
{
// Code to execute if condition1 is true
}
else if (condition2)
{
// Code to execute if condition2 is true
}
// ... (more else if conditions)
else
{
// Code to execute if no condition is true
}
Decision control Branching statements
>Nested If Statement: A nested "if" statement is an "if" statement inside
another "if" statement. This is used when you want to check additional
conditions based on the result of an outer condition.
Syntax:
if (outer_condition)
{
if (inner_condition)
{
// Code to execute if both conditions are true
}
}
Decision control Branching statements
>Switch Case Statements: A "switch" statement is used to select one of many code blocks to be executed.
It's like a multiple-choice menu. You provide a value, and the program matches it to a predefined list of
values (cases) and executes the corresponding code block.
Syntax: switch (value_to_check)
{
case option1:
// Code for option1
break;
case option2:
// Code for option2
break;
// ... (more cases)
default:
// Code if none of the cases match
break;
}
Simple if statement
PROGRAMS:
Join us in telegram- click here
Join us in telegram- click here
Join us in telegram- click here
Join us in telegram- click here
Join us in telegram- click here
Join us in telegram- click here
Join us in telegram- click here
If-else statement
PROGRAMS:
Join us in telegram- click here
Join us in telegram- click here
Join us in telegram- click here
Join us in telegram- click here
Join us in telegram- click here
Join us in telegram- click here
Join us in telegram- click here
Join us in telegram- click here
Join us in telegram- click here
If-elseif statement PROGRAMS:
Join us in telegram- click here
Join us in telegram- click here
Join us in telegram- click here
Join us in telegram- click here
Join us in telegram- click here
Join us in telegram- click here
Join us in telegram- click here
Join us in telegram- click here
Nested if statement PROGRAMS
Join us in telegram- click here
Join us in telegram- click here
Join us in telegram- click here
Join us in telegram- click here
Join us in telegram- click here
Join us in telegram- click here
switch case statement PROGRAM
Join us in telegram- click here
Join us in telegram- click here
Join us in telegram- click here
Join us in telegram- click here
Join us in telegram- click here
Join us in telegram- click here
For more programs join us In
telegram Join us in telegram- click here