C++primer the Fifth chapter

Source: Internet
Author: User
Tags case statement switch case

//1. The function of an expression statement: Executing an expression and discarding the evaluation result    intValue =Ten; Value+5;//Execute, and discard the result//2. A compound statement is a sequence of statements and declarations enclosed in curly braces, called blocks. A block is a scope. The block does not end with a semicolon. //3. Add curly braces after the if else while, etc. to help the program read. //The 4.else matches its closest unmatched if match. //in a 5.switch case statement, the case label must be an integer constant expression. //The switch statement should preferably have default, which is intended to indicate that the defaults are currently taken into account. //C + + stipulates that an initialization statement that crosses a variable is not allowed to jump directly to another location within the scope of the variable.     Switch(value) { Case 0:        {            inti = +;//right, because I is in the block scope             Break; }     Case 1:        intJ//correct, and no initial value specified for J//int k = 0; //error, "K" Initialization action skipped by "case" tab         Break;  Case 2: J=Ten; printf ("%d\n", j);//if value is 2, the output         Break;  Case 3: printf ("%d\n", j);//if value is 3, the output is chaotic .         Break; default:         Break; }//6. Do not use Goto in the program, which can cause the program to be difficult to understand. 

C++primer the Fifth chapter

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.