+ 1

GOTO algorithm step

Is there any code line in any programming language that works like this algorithm:- Step 1: Start Step 2: Read Health Step 3: Is Health==0 If yes, GOTO step 4 If no, GOTO step 5 Step 4: Keep playing match Step 5: Quit match Step 6: Stop Code not necessary, explanation works.

23rd Apr 2021, 2:40 PM
Shikaki Van D Wolfgang Sebastian
Shikaki Van D Wolfgang Sebastian - avatar
2 Réponses
+ 3
Several programming languages support goto, including C, C++, C#, D, PHP (>=5.3), Perl. In python you could write it similar to this: health = int(input()) if health == 0: continue # keep playing match else: break # or return
23rd Apr 2021, 2:53 PM
Benjamin Jürgens
Benjamin Jürgens - avatar
+ 2
Using GOTO is considered bad programming. It's sort of a lazy way to "jump around". Naturally there are cases where it can be used elegantly, but try to avoid it. I've never used GOTO. In most cases you will use BREAK or IF types of statements to control the flow.
23rd Apr 2021, 3:29 PM
Jerry Hobby
Jerry Hobby - avatar