presentation_jumping_statements_.ppt

508 views 10 slides Mar 12, 2023
Slide 1
Slide 1 of 10
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10

About This Presentation

This is about the unconditional control statement


Slide Content

Jumping Statements
T.KARTHIKEYA
---22J41A05R1

Types of jumping statements
break
continue
goto
return

break statement
Break statement is used to exit from a loop or a
switch case statement.
Generally we exit from a loop when logical
condition becomes false but if we want to exit
the loop before the logical condition becomes
false then we can use break statement.

Example
void main()
{
int x=1;
while(x<=10)
{
printf(“%d\n”, x);
if(x = = 5)
{
break;
}
x++;
}
}
OUTPUT:
1
2
3
4
5

continue statement
Continue statement is used to move the control
to the next repetition of the loop.
We can use continue statement only inside
loops.

Example
void main()
{
int x=1;
while(x<=10)
{
if(x % 3 = = 0)
{
x++;
continue;
}
printf (“%d \n” , x);
x++;
}
}
OUTPUT:
1
2
4
5
7
8
10

goto statement
goto statement is used for unconditional
jumping.
We can move the control from any part of the
program to any other part of the program with
the help of goto statement.

Example
void main()
{
printf(“Hello \n”);
goto abc;
printf(“Welcome \n”);
abc:
printf(“Good Morning”);
}
OUTPUT:
Hello
Good
Morning

return statement
Return statement is used to return a value from
a function.
The value is returned to the place where the
function is called.