-
If-goto Loop
Hey guys,
I have an assignment due for thursday and this is one of the questions
Here is a for loop:
1. for i equals 1 to 10
2. an instruction
3. another instruction
Rewrite this loop in if-goto language.
The problem is, I have no idea what if-goto language is :/ it;s really confusing me, hoping someone can offer me some help
-
Re: Java question
if-goto is what it sounds like:
If something is true, goto somewhere else.
For example:
1. ask user for input
2. if invalid input: Goto 1
3. process input
This will keep asking the user for inputs until what they enter is valid.
In current programming practice goto should be avoided as it has a tendency to produce "spaghetti code" (code that's hard for humans to read/understand). It has it's uses and is a must in assembly/machine language, but you really shouldn't be programming at that level if you don't have to.
Obligatory XKCD comic on GOTO
--- Update ---
Please don't post the same question under multiple categories. I've moved stuff around so you only have one thread.
-
Re: If-goto Loop
Thanks for the reply, sorry about posting in multiple categories.