vendredi 18 janvier 2019

Which is the best algorithm for exiting the loop after 100 cycles?

I'd like your opinion on this basic question about loop structure.

Below are two algorithms (created using Raptor) that prints 'Hello World' a hundred times. Which is the best algorithm in terms of 'best practices'?

Is it the first example because the condition is easier to understand or is it the second since the condition has 'control' over the print statement also? Or is it just personal preference?

I have checked some comments about best practices for loops online and it seems that simplicity is more important? I'd appreciate your ideas about these examples here.

two flowcharts showing both algorithms

Aucun commentaire:

Enregistrer un commentaire