C while loop loop. Please help...

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

    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.

    Your ** changed to a while loop is as follows:

    inti=0;

  2. Anonymous users2024-02-04

    Just put the program inside the while.

    while(true)

  3. Anonymous users2024-02-03

    Refer to the following: 1) For the console program, get the input score on the console, then save it to an array or collection, and then use the traversal or for loop to output the score to the console.

    2) Windows Form, you can enter the score on the textbox control, save it to an array or collection, and then use the traversal or for loop to output to the textbox and then listbox or other controls.

  4. Anonymous users2024-02-02

    The while loop is an expression after the while parentheses.

    To make a judgment of truth or falsehood, for example, there is such a provision in the language A and C you use, if a=0; Then alas

    If a is not 0, then he is true, therefore, the above loop, as long as a is not equal to 0, then the cycle goes on all the time.

    When I first started learning, I always thought that it was only true when it was equal to 1, and he couldn't loop if it was equal to 2, but that was wrong, the compiler.

    The criterion for judging the true or false conditions is that he is not equal to 0, not equal to 1, the landlord remembered

    There is also,If the landlord's will is to let a=0 exit the loop,Then you can follow the method you wrote,If the will of the landlord is to let a=0 when the cycle is made,Then Pei Huainian has 2 ways to write。

    while(!a)

    Non-operation on A.

    And there is. while(0==a)

    It is recommended to write 0==

    The form of a, in fact, 0==a, is essentially the same as a==0, but if you say 0==a and write it as 0=a, then the compiler will report an error, and the compiler will .

    If a==0 is written as a=0, the compiler will not report an error, which can reduce the risk.

    Good luck!

  5. Anonymous users2024-02-01

    Meaning if a

    If true, execute the loop body in while!

    a) Cycle conditions for town and bend! But an endless loop! Because there is no way to determine whether the value of a is true or false!

    Write an example!

    inta=0;

    while(a<5)

    a++;printf("%d",a);

    When a=0, a<5 is judged to be true! Perform the loop body!

    This cycle is a total of 5 times! That is, you can run A++ 5 times and see what the effect is every time! It can deepen your understanding of the cycle!

    Hope it helps!

  6. Anonymous users2024-01-31

    The syntax of while is.

    while (expression).

    When the expression is not 0, the sentence buried in the sentence body will be executed.

    It doesn't stop until the expression is 0.

    The while statement is generally used in an endless loop.

    So the regular usage is while(1).

  7. Anonymous users2024-01-30

    The while loop statement of the C language loop structure.

  8. Anonymous users2024-01-29

    while(1){} is an endless loop, the same goes for while(1); It may be easier to understand the endless loop, for(i=0; i<10;i) {} looped 10 times; for(i=0;i<10;i);The same loop is 10 times, but the latter one does not execute the statement, while(!ri)

    Execute when ri is true, that is, execute this when ri is 0 is also an endless loop, if you want to jump out of the loop.

    for(;;

    test...

    if(..break;

    In the same way, when the conditions are met, the for loop is jumped out, the endless loop is ended, and the program outside the for is executed.

    Does that make sense?

  9. Anonymous users2024-01-28

    Find the tired 2113 plus value of 1-100 plus 5261, but skip the 4102 and all 1653-digit versions.

    is a number weight of 3.

    intsum=0;

    charbuffer[20];

    for(int

    i=1;i<101;i++)

    elsesum+=i;}

    itoa(sum,buffer,10);

    printf(

    s"buffer);

Related questions
13 answers2024-02-08

Hello! Cell biology has.

It only represents a personal opinion, don't spray if you don't like it, thank you. >>>More

14 answers2024-02-08

Remove impurities in the circulating water system due to atmospheric capture, surface peeling of pipe fittings, and flocculation of impurities in the water supply. Protects the circulatory system from deposition, fouling, etc.

16 answers2024-02-08

This is not a proposition, or a false proposition. It should be said that the numbers in all real numbers, except for rational numbers, are irrational numbers and true propositions. >>>More

11 answers2024-02-08

In C++, vector is used as a container, and its function is to store variables of struct type. Here's how vector might be used: >>>More