0
How Can i guess the correct number that will result from the loop ?
as you know there is a lot of questions about the loop but I still don't know how can I know exactly guess the number that will result , I find a difficult because the loop is used to print a value many times that means that there's many numbers may be printed, what i have thaught is that the answer is the last number before the loop ends ,so what's the solution? so can someone help me?
3 ответов
+ 2
depends on rules of language, type of loop, e.g. do while and while are different, and the incremental or decremental factor, again e.g. >10 means 11 where >=10 means 10. Best is to say it as you read it, greater than, greater than OR equal to... etc.
+ 2
Sometimes, it's nice to know what your loop would produce, especially when you need a specific outcome. However, if your loop makes use of randomness for its output, you might not even have a clue; only a range of values might be all you have.
A lot of times, you may need to fine-tune the values you feed the loop. All with trial and error. For simple loops where you increase/decrease a variable's value by a fixed value, use Newton's first equation of motion: v = u + at. Where u is the starting value, a is the incremental value and t is the number of iterations.
Well, that's all I have for now.
0
Anyway thanks a lot my Friend John and Andre for your answers ! it's really interesting!