What does it mean in a while loop statement?

Updated on technology 2024-04-06
8 answers
  1. Anonymous users2024-02-07

    while(deno<=100) When deno is less than or equal to 100, execute ** in brackets below.

    sign=-sign;Changing the symbol of the sign variable is equivalent to multiplying it by -1 and saving it in sign.

    term=sign/deno;Divide the quotient of sign by deno and assign it to term

    sum=sum+term;I add term to the original value of sum and save it in sum.

    deno=deno+1;Save the deno plus again and again in the deno.

    When while is executed for the first time, sign=-1, term=-1, sum=1+(, den0=3

    When while is executed the second time, sign=1, term=1 3, sum=, den0=4

    This app is counted: 1-1 2+1 3-1 4+1 5....1 99-1 100 results and output.

  2. Anonymous users2024-02-06

    This should be calculated as -1 2+1 3-1 4+......1 of 100. term=sign deno is used to assign each fractional value to term, which is then added in the next step.

  3. Anonymous users2024-02-05

    The usage of the while loop statement is:

    1. After the while loop starts, first judge whether the conditions are satisfied, if it is satisfied, execute the statement in the loop body, and then come back after the execution is completed to judge whether the conditions are met, and so on infinitely; When the conditions are not satisfied, execute the statement after the while loop. To put it simply, the while loop is judged first and then the loop, and if the conditions are met, the loop is entered and judged again.

    2. While is a basic cyclic pattern of computers. When the condition is met, it enters the loop, and when the condition is not met, it jumps out after executing all the statements in the loop (instead of jumping out of the loop immediately). The general expression for a while statement is:

    while (expression).

    The difference between a for loop and a while loop

    1. Different usage scenarios: for is generally used when the number of executions is known, and while is generally used when the condition loop is used.

    2. The difference between the two types of loops in ordinary loops: when looping an array, generally speaking, if each round of loops is after the loop is processed, it is more convenient to use the for loop.

    If you want to increase the loop variable during loop processing, it is more convenient to use a while loop.

    Also, when using the for loop statement, if the loop condition in it is very long, you can consider using a while loop instead to make the typography format of ** look better.

    while not

    1. Avoid making the conditions of the cycle forever true or forever false, otherwise it may be meaningless;

    2. Don't add it after while;

    3. The curly braces behind the while loop can be omitted, if omitted, it can only affect the sentence closest to it, and this sentence cannot be a declaration variable;

    4. The variables defined in the while statement block cannot be outside.

  4. Anonymous users2024-02-04

    while(0) means that the loop is not executed once, which is equivalent to while(0!=0)while(1) means that the loop is executed forever, and you can jump out of the loop by breaking in the loop.

    Equivalent to while(0==0).

    a !=0 means that a is not equal to 0 a can be a non-zero positive arbitrary number, then the condition is zhi can execute the loop;

    A ==1 When the value of a is 1, the condition is true, and the loop can be executed;

    One is that when the value of a is not 1, the loop can be interrupted and executed;

    One is that the value of a can only be executed if the value is 1.

  5. Anonymous users2024-02-03

    while(1) where 1 represents a constant expression, and while(1) represents an infinite number of years and loops, which will only be aborted unless you set a break or other similar pop-out loop statement.

    while(i--) where i is a variable, so the expression i--has different values, decreasing in turn, i-- is the value taken first and then subtracted,-- i is added first and then the value is taken, so the value of i-- is equal to i when the self-reduction operation is not performed.

  6. Anonymous users2024-02-02

    1. The while loop is executed once first, that is, when the loop is released, judge whether the while condition is true, and jump to do to continue the loop; False, exit the loop, execute the next line**.

    2. While is a basic cyclic pattern of computers. When the conditions are met, it enters the loop, and after entering the comma loop, when the conditions are not met, it jumps out of the loop. The general expression of a while statement is: while (expression).

  7. Anonymous users2024-02-01

    In C, a while loop statement is a control statement that is used to repeat a paragraph when a specified condition is met. The syntactic structure of the while loop statement is as follows:

    while (condition) {.}

    Circulating bodies. In a while loop statement, a condition is a Boolean expression that indicates the condition for determining whether the loop continues to execute. When the value of the condition is true, the while loop executes the ** in the loop body; When the value of the condition is false, the while loop ends and the loop body is popped out.

    For example, the following ** uses the while loop statement to output numbers from 1 to 10:

    #include

    int main()

    int i = 1;Define the cyclic variable i

    while (i <=10) {Execute the loop body when i is less than or equal to 10. }

    printf("%d", i);Output the value of i.

    i++;Add the value of i by 1

    return 0;

    In this example, we define a cyclic variable called i and use its value in the condition of the while loop. Each time you loop, the value of i is output, and then the value of i is increased by 1. When the value of i is greater than 10, the while loop ends and the loop body is popped out.

    It needs to be noted that the while loop statement first determines the condition and then executes the loop body, so if the value of the condition is false at the beginning, then the ** in the loop body will not be executed. For example, in the ** above, if the initial value of i is set to 11, then the condition of the while loop will be directly false, and the ** in the loop body will not be executed.

    In addition, a while loop statement can also use a break statement to interrupt the loop, ending the loop and jumping out of the loop body. For example, you can add a condition judgment to the loop body, and if the condition is true, call the break statement to exit the loop.

  8. Anonymous users2024-01-31

    The prototype of the while statement is a while statement, and when the expression is a non-0 value, the nested statement in the while statement is executed.

    while(1) where 1 represents a constant expression, which will never be equal to 0. The cycle will continue to be executed. Unless you set a break and other friends shout something like a pop-out loop statement, the loop will be aborted.

    while(i--) where i is a vertical key variable, so the expression i--has different values, decreasing in turn, i--is to take the value first and then subtract,-- i first add and then take the value, so the value of i--is equal to i when the self-reduction operation is not performed. So when i is 0, the loop jumps out.

    The general form of a while statement is:

    while statement.

    where the expression is the loop condition, and the statement is the loop body.

    The semantics of a while statement is to evaluate the value of the expression, and when the value is true (not 0), execute the loop statement.

Related questions
11 answers2024-04-06

He is the vice-captain of the Red-Haired Pirates.

14 answers2024-04-06

Meaning: It means to be bullied. The Breath Dictionary explains: >>>More

8 answers2024-04-06

The Oxford English Dictionary has an analysis on page 136 of the second line of the number, so I suggest you look it up.

34 answers2024-04-06

SP is an individual who is randomly assigned to a guard or an act of God so that you can avoid a black shop.

14 answers2024-04-06

The meaning of Lao A in "Soldier Assault" is: a fictional special forces. >>>More