C Language Learning notes-5. Cyclic structure programming

Source: Internet
Author: User

One, for statement, while statement, Do-while statement

  1. Features

  for while do-while
0 0 1
judging mode Initialize->  first judge and execute first after the judgment
Pros and cons more convenient to use when the loop is clear It will be executed at any time

2.do-while statements are often used to resolve fragile input patterns

Char choice;  Do {    scanf ("%c", &while'y  'n');

3.do-while statement with a semicolon

Two, break statement and Continue statement

  1. When the break statement is executed, just jump out of the layer loop that surrounds it recently

2.goto Keywords: More for exception handling, try not to use

Example: if (error) goto error;

error:printf ("Error");

Iii. Examples of procedures

  1. Random number: rand () can generate an integer between 0~rand_max (0X7FF)

Header file: Stdlib.h set Seed: Srand ((unsigned) time (NULL)); Need to Time.h header file

C Language Learning notes-5. Cyclic structure programming

Related Article

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.