0% found this document useful (0 votes)
23 views

Conditional Branching Statements

The document discusses different types of branching and control statements in C including conditional statements like if, if-else, and switch statements. It also covers looping statements like while and do-while loops. Finally, it describes jumping statements such as break, continue, goto, and return that alter the normal flow of a C program.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Conditional Branching Statements

The document discusses different types of branching and control statements in C including conditional statements like if, if-else, and switch statements. It also covers looping statements like while and do-while loops. Finally, it describes jumping statements such as break, continue, goto, and return that alter the normal flow of a C program.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Branching/control statements :-

Conditional Branching Statements:


In C, conditional branching statements are used to execute particular code blocks based on a condition
(as needed). These branching instructions in C allow programmers to run the code only when specific
conditions are met. The various categories of conditional branching statements in C are as follows:

o if Statement
o if-else Statement
o nested if-else Statement
o switch Statement

if Statement

This statement is used to execute the specific block of code if a certain condition is
evaluated to be true.

Syntax of if Statement in C

Here is the syntax of the if statement in C.

if (condition) {

statement 1….;

else Statement

The else Statement in C is considered just the opposite of the if statement. This statement is
used to execute the code if the condition specified in the if statement evaluates to false.

Syntax of else Statement in C

Here is the syntax of the else Statement.

if (condition) {

// statemnets

} else{

// code executed if condition is false


}

I++ and i--

I++ means Use I, then increment it. ++I means Increment I, then use it. I-- means Use I, then
decrement it. --I means Decrement I, then use it.

While and do while


while loop:
A while loop is a control flow statement that allows code to be executed repeatedly based on a
given Boolean condition. The while loop can be thought of as a repeating if statement. Syntax :
while (boolean condition)
{
loop statements...
}
Flowchart:
do-while loop:
do while loop is similar to while loop with the only difference that it checks for the condition after
executing the statements, and therefore is an example of Exit Control Loop. Syntax:
do
{
statements..
}
while (condition);
Flowchart:

Jumping statements
In C, jump statements are used to jump from one part of the code to another altering the normal flow of the
program. They are used to transfer the program control to somewhere else in the program.
In this article, we will discuss the jump statements in C and how to use them.
Types of Jump Statements in C
There are 4 types of jump statements in C:
1. break
2. continue
3. goto
4. return
1. break in C
The break statement exits or terminates the loop or switch statement based on a certain condition, without
executing the remaining code.
Syntax of break in C
break;
Flowchart of break Statement

Continue in C
The continue statement in C is used to skip the remaining code after the continue statement within a loop and
jump to the next iteration of the loop. When the continue statement is encountered, the loop control immediately
jumps to the next iteration, by skipping the lines of code written after it within the loop body.
Syntax of continue in C
continue;
Note: Just like break, the continue statement also works for one loop at a time.
Flowchart of continue Statement

You might also like