while Introduction to Cycling in C

Updated on technology 2024-05-23
9 answers
  1. Anonymous users2024-02-11

    There are generally 2 ways to use while.

    1. While (judgment condition).

    Circulating bodies. Examples:

    int sum=0,i;

    while(i<5) When i<5, it enters the loop body.

    sum+=i;Sum up.

    2. There is also a while usage: this is to execute do first and then make a while judgment. Regardless of whether the while condition is met or not, the do loop is executed first.

    So while and do....The biggest difference while is: do....while executing the loop body at least once.

    DO Loop Body.

    While example: do

    sum+=i;

    while(i<5)

  2. Anonymous users2024-02-10

    format: while(condition) { The condition is the result of the boolean type.

    Executor. Execution ideas:

    First, enter the condition judgment, if it is true, enter the loop, run the executor**, and update the variables.

    Enter the judgment again, and so on, until the condition is false, and the loop is jumped.

  3. Anonymous users2024-02-09

    while (expression).

    **Segment. If the expression is true, the ** in the execution is executed, and then go back to check whether the expression is trueDoesn't end the loop as true.

    Otherwise, the ** in the process of continuing. Note: Add a statement that changes the value of the expression in **, otherwise it will cause an endless loop.

  4. Anonymous users2024-02-08

    Same as any other programming language.

  5. Anonymous users2024-02-07

    c From beginner to proficient, there are detailed instructions in it, which can be referred to below.

  6. Anonymous users2024-02-06

    The cycle of C is exactly the same as that of C++.

    while statement.

    while statement"Dang type"loop, its general format is:

    initialization]

    while (termination)

    1.When the value of the Boolean expression is true, the statement in curly braces is executed. And the initialization part and the iteration part are optional.

    The statement first evaluates the termination condition, and when the condition is satisfied, it executes the statement in the loop. It is"Dang type"Characteristics of the cycle.

    do-while statement.

    do-while statement"Until the type"loop, its general format is:

    initialization]

    dowhile (termination);

    The statement first executes the loop body, then evaluates the termination condition, and if the result is true, the loop executes the statement in curly braces until the result of the Boolean expression is false.

    2.Unlike while statements, the loop body of a do-while statement is executed at least once, yes"Until the type"Characteristics of the cycle.

    for statement.

    The for statement is also used to implement this"Dang type"loop, its general format is:

    for (initialization;termination;iteration)

    When a statement is executed, the initialization operation is performed first, then the termination condition is satisfied, if so, the statement in the loop is executed, and finally the iteration part is executed. After a cycle is completed, the termination condition is re-evaluated.

    2.You can declare a variable in the initialization part of the for statement, and its scope is a for statement.

    Statements are typically used to perform cases where the number of loops is determined, such as when operating on an array element, or where the number of loops is indeterminate depending on the loop end condition.

    4.In the initialization and iteration sections, you can use comma statements to perform multiple actions. A comma statement is a sequence of statements separated by a comma. For example:

    for(i=0,j=10;i5.The initialization, termination, and iteration parts can all be empty statements (but semicolons cannot), and when all three are empty, it is equivalent to an infinite loop.

  7. Anonymous users2024-02-05

    Do while when you make a judgment. for is the first judgment to do. That is, the former will be executed at least once and the latter may not be executed once, so much difference.

  8. Anonymous users2024-02-04

    Do whlie loops are cycles that meet the conditions and are suitable for trials without knowing the number of loops!

    For loop is to specify the number of loops to loop, if you don't know the number of loops, it's best not to use it!

  9. Anonymous users2024-02-03

    do...while executes the loop body once and then determines the loop condition (whether the loop condition is true or false).

    for first determine the loop condition, and then execute the loop body (if the loop condition is false, it will not be executed once).

Related questions
9 answers2024-05-23

Let's talk about the difference between foreach and for, foreach is traversal for objects, and there is no need to define the number of loops, but there is a disadvantage, foreach traversal takes read-only data, and cannot add, delete and modify objects in foreach, while for loops can. >>>More

5 answers2024-05-23

1. The pointer of the last node points to a different point. >>>More

9 answers2024-05-23

As a suggestion for you, C Introductory Classics is a good book. But there is one point, if your comprehension ability is not particularly strong, you can take a look at some ** tutorials such as msdn, but I don't recommend him, I recommend you individually, because he uses VS2005, I think the tutorial he gave, the example tutorial is very good! Check it out!

4 answers2024-05-23

The date controls commonly used in C are the DateTimePicker and the MonthCalendar control, the former can only be used for one date, and the latter can choose the start date and end date, but the former is easier to use. >>>More

6 answers2024-05-23

dataset ds = new dataset();A dataset.

sqlconnection con=new sqlconnection("server=.;database=database name; uid=sa;pwd=sa"); >>>More