Basic for loop usage

Source: Internet
Author: User

1. Format: for (preparation; condition; Adjustment) {} 2. Basic and related knowledge points 1) analysis of the number of occurrences in the for loop. For (1 time; more than 1 time; more than 0 times) Note: semicolon; is required. But none of the items in the brackets is required. 2) continue. Jump out of this loop and enter the next loop. 3) in any loop, the continue and break 4) sum/10 substatements can obtain integers. To get a decimal number, you can process sum/10.0 or 1.0 * sum/10 in this way. That is to say, at least one is a decimal number. 5) (double) sum note that this formula does not convert sum to the double type, and the value represented by the second 18 sum is converted to the double type. Once the type of a variable is determined, it remains unchanged for life. 6) int sum; sum + = 2; in this case, junk data may be generated. Because sum is not initialized. This problem does not occur in java. Think that the default value of int type variables in java is 0; 7) Get used to printf ("% d", ++ I. 3. The following are attached with several routines. 1) 2)

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.