1.3.4break, continue and GOTO statements
1.3.4.1break statement
Break statements are usually used in circular statements and in switch statements. When the break is used in switch statement switches, the program can jump out of switch and execute a switch statement, and if there is no break statement, it becomes a dead loop and cannot exit. The use of the break in the switch has been encountered in the example described earlier in the switch statement, which is no longer an example.
When a break statement is used in a do-while, for, and while Loop statement, the program terminates the loop and executes the statement following the loop, and usually the break statement is always associated with the IF statement. That is, when the conditions are met, they jump out of circulation.
Example 19:
Main ()
{
inti=0;
Charc;
while (1)/* Set Loop * *
{
C= ' "; /* Variable Assignment initial value * *
while (c!=13&&c!=27)//keyboard receives character until press ENTER or ESC key * *
{
C=getch ();
printf ("%c\n", c);
}
if (c==27)
Break /* To determine if the ESC key to exit the cycle * *
i++;
printf ("theno.is%d\n", I);
}
printf ("theend");
}
Attention:
The 1.break statement does not work for if-else conditional statements.
2. In a multi-layer cycle, a break statement jumps only one layer.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.