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

Source: Internet
Author: User
Tags alphanumeric characters

1, the knowledge points learned in this lesson:

①, character-based data

(1) Character type constants

(2) Character type variable

②, character type data input and output

(1) calling function scanf () and printf () input and output characters

(2) Character input function GetChar ()

(3) Character output function Putchar ()

③, logical operations

The expression of logical operators: logical non! , Logic and &&, logic, or | |

④, switch statements

Can handle multi-branch selection problems, and three ways to use break statements

The mastery of ⑤ and several basic constant expressions

⑥, distinguishing numeric and alphanumeric characters

2, the experimental process encountered problems and solutions:

(1) characters are enclosed in a pair of single quotes, not double quotation marks.

(2) Use in Logical expressions (): For example: (ch>= ' a ') && (ch<= ' z ')

(3) When the discovery program is not running, you need to check the details carefully

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

C language learning has been nearly one months, there are a lot of trivial knowledge need to be a little bit together to make a complete program. Many of us need to remember, we have to learn more practice.

4, learn the C language programming one months since the harvest and summary:

One months of time said not long also not long said not short also is not short, learned a lot of things, opened the textbook will know what to learn. Some things may not understand in place, but more days is not, I will continue to work hard, strive to do better, to grasp the knowledge. When their own complete knock out a code, run successfully, can not speak their own inner joy, I think this is the joy of learning it!

5, small exercise: write down the following conditions of the C-language expression

(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

6, preview the cycle structure while and do-while

(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.