What are the differences between the repeating structures while, repeat and for?

Asked

Viewed 6,018 times

2

Friends, I am learning programming logic and this doubt came when I should use these commands and their differences.

  • Could you give examples? Unless it is a specific language, these terms (or their correspondents in English) are sometimes used with slightly different meanings from language to language, making it difficult to respond out of context. If you don’t have examples, at least a reference to where you saw these terms.

  • I am learning Portuguese programming logic.

1 answer

7

FOR - For a number of repeats already defined, or even when you need to count repetitions, and even when you want to read an array from the last to the first element.

AS LONG AS - When your code has the amount of indefinite repeats and depending on one or more conditions to stop the loop.

REPEAT - When the loop is required to run at least once. The code block inside the loop will run the first time without the condition being checked.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.