The Gateway to Computer Science Excellence
+5 votes
An unrestricted use of the “goto” statement is harmful because
(a) it makes it more difficult to verify programs
(b) it increases the running time of the programs
(c) it increases the memory required for the programs
(d) it results in the compiler generating longer machine code
in Programming by | 3k views

3 Answers

+11 votes
Best answer

(a) it makes it more difficult to verify programs
goto in no way can increase the running time or memory requirement of the program. It also doesn't contribute to longer machine code. But the use of goto can result in unstructured code and there can be blocks with multiple entry and exit points which can cause a nightmare for program verification. 


selected by
Why it wont increase time?Wont it create stalls in assembly language code?
@rahul Any branch condition will cause stalls theres nothing harm done exclusively by "goto".

Question asked the reason for restriction on goto.

If stalls are a concern why only goto would be restricted?

goto is branch condition and it will create stalls even that can't be managed  like other (stalls created by dependency ).

and if stalls are there then CPI increases ... obviously  not CPI =  1. and when CPI increases then execution  time will increases. .. so according to me  OPTION B is more appropriate.  


answer  please

goto is a branch condition its true but Branch condition  cause stalls and then it results in longer running times.

but here we have to select most appropriate option and option b seems more generic not very much specific to question

but you see in goto statements control flow changes abruptly (its properly defined in loops) so its difficult to verify the program or simply predict the working of the program.

thats what i think it may have some corrections

@G.K.T   difficulties  in verifying  the program .... doesn't  it seem weak option  . we ultimately  do worry  about time complexity.  that is the prior  goal .

 so a/c to me option B

Actually I think it solely depends on the situation . Time Complexity is a major criteria but what if there will be a scarcity of memory resources ?

then we need to focus on space complexity. no?

similarly in question the word "unrestricted" is used for a reason as unrestricted means difficulty in judging the flow of control.

now how a is a weak option ?

Why is option C wrong?
0 votes
I think answer will depend on program size and page size

in this question if we consider program size is large and can't fit in 1 page then goto may point to different pages at different times so more time will be required (for page replacements)also if we say time taken for execution is to be minimized( page replacement  time is less) then main memory should be more to accumulate all the pages so there is a tradeoff between time and memory so what should be the answer of this question?? as no program size is given
0 votes
If we use "goto" statements then it leads to structural decomposition of code then it is difficult to verify the programs.

Dijkstra's argued that unrestricted goto statements should abolished from the higher-level languages because they complicated the task of analyzing and verifying the correctness of programs.
Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
52,345 questions
60,470 answers
95,272 users