I dont understand. Why is the answer of the question below 10?
“Consider an Int32 variable (counter), initially assigned with the value 10. The value decreases by 1 every time a sequence is executed in a Do While activity.”
Can you explain it for me?
Thank you.
Hi @Dam_Son !
Welcome to UiPath Community
If the output is 10, that means that probably:
- the default value was not set to 10 (but propably 11) + the robot got only once in the do while because the condition was not met (so from 11 it went to 10)
- or inside the do while, there is an assign with the int32 that is hardly coded with 10 (so every time it gets inside the loop, it’s put back to 10)
Would you mind showing us your workflow (xaml file) or screenshot your code so we understand your context ?
Please think of @Hiba_B points as well,
could you plead find below image and let us know?
bot will keep on executing code of inside do while until intNo is 0. here condition becomes false, will be out of do while loop.
Cheers,
Pankaj
Thank you very much for your reply. I’m very sorry that I didn’t post the full question (it is a quiz from " Variables, Data Types and Control Flow" course). Here is the full question (I don’t know how to edit my post):
" Consider an Int32 variable (counter), initially assigned with the value 10.
The value decreases by 1 every time a sequence is executed in a Do While activity.
How many times will the sequence be executed if the expression in the Condition field of the Do While activity is V > 0?"
The answer is 10. After thinking for a while, now I know why it is 10.
So, if I use While
instead of Do while
, the answer is still 10, right?
Thank you very much for your help. I’m sorry for making you confused. It is not a full question. I did post my full question above this comment.
The difference between while and do while is the following:
- do while means the robot loop once then checks the condition, then if the condition is met it keeps looping
- while means that the robot checks first if the condition is met before entering in the loop
Yes it will loop 10 times also with a while loop