Chapter 6: Statements

Source: Internet
Author: User
Tags case statement

1. When using the switch-case statement, note that the expression must produce a positive result and its value is compared with the value of each case.

2. variables defined in the loop condition must go through the creation and revocation processes in each loop.

3. The break statement is used to end the recent while, do-while, for, or switch statements, and pass the execution permission of the program to the statement that follows the terminated statement.

Example:

Int I = 5;

While (I)

{

Switch (I)

{

Case 1:

I --;

Break;

Case 2: // Loop

I --;

I --;

Break;

}

I --;

}

Cout <"I =" <I <Endl;

In this example, note that when I = 2, after the statement at the loop is executed, I = 0. At this time, the I --, this leads to an endless loop.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.