Experiment four--multi-branch structure and summary of this chapter

Source: Internet
Author: User

1. The knowledge points learned in this lesson:

(1) Representation of a character-type constant

(2) Character variable type name char and character type variable op

(3) Character input function GetChar () function is a character that will be entered and assigned to a character variable

(4) Logical operator: logical non! , logic and &&, logical OR | |.

(5) switch statement: can handle multi-branch selection problem, break statement of three ways to use.

(6) Nested IF statements (ELSE-IF statements, if-else statements), and switch statements can implement a multi-branch structure.

2. Problems encountered during the experiment and solutions:

(1) The expression in the switch statement does not know what to enter when encoding

(2) Do not understand the role of Char op in the program

(3) GetChar (), Putchar () can only handle the input and output of a single character, so in the input of more than one character to pay attention to, in the way of circular calls

3. Experience of experiment and summary of the study in this chapter

From this job, I basically understand the function of the branch structure, can make use of the switch statement simple topic, but always in the character output function problems.

4. Learn the C language program one months of harvest and summary

One months of time passed quickly, I from just touch C language of no clue, to now through their own understanding of C language can make some basic procedural problems, the heart is a little bit proud of (~ ̄▽ ̄) ~. However, the difficulty of C language in these several studies only gradually manifested, is no longer the original program template, so more need to understand and serious learning attitude. I believe that with the help of teachers, can continue to maintain the C language learning enthusiasm, proficiency in C language.

5. Exercise: C-language expressions that write the following criteria

(1) (ch== ") | | (ch== ' \ n ')

(2) (ch>= ' A ' &&ch<= ' Z ') | | (ch>= ' A ' &&ch<= ' Z ')

(3) (number>= ' 0 ') && (number<= ' 9 ')

(4) (chinese>=80) && (math>=80) && (english>=80)

(5) (chinese>=80) | | (math>=80) | | (english>=80)

(6) (a>c) && (b>c)

(7) (a<b) | | (A<C)

(8) (n%3==0) | | (n%5==0)

(9) (score>=70) && (score<=80)

(Ten) Number%2==0

5. Preview the while and do-while in the loop structure

(1) Whlie: For the realization of the loop, its application surface is more extensive than the for statement, the general form is:

Whlie (expression)

loop body statement;

① execution Process: When the expression value is true, the loop executes until the value of the expression is false, the loop terminates, and the next statement is looped.

② expression can be any legal expression, the loop body statement can only be a statement

③ constitute a simple, an expression is a cyclic condition, a loop body statement is a loop body

④whlie's loop body statement must contain operations that can eventually change the authenticity of the loop condition

(2) do-whlie:do{

Loop Body Statement

}whlie (expression);

① execution Process: the first time into the loop body, first execute the Loop body statement, and then check the loop control condition, if the value is true, continue the loop until the value is False, the loop ends, the next statement executes Do-whlie.

② expression can be any legal expression, the loop body statement can only be a statement

The ③ is used with an additional initialization, and the loop body statement must contain operations that can eventually change the authenticity of the loop condition.

④ the loop body first, then the cycle condition is judged.

(3) The same point: the expression can be any legal expression, the loop body statement can only be a statement, the loop body statement must contain can eventually change the loop condition of the authenticity of the operation.

(4) Different points: Whlie, for first judge the condition, the condition satisfies after enters the circulation

Do-whle the loop body first, then the cycle condition is judged.

Experiment four--multi-branch structure and summary of this 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.