The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+3 votes
1k views
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
asked in Programming by Boss (6.3k points) | 1k views

1 Answer

+7 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. 

 

answered by Veteran (14.6k points)
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?
@G.K.T  

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 ?

Related questions



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

32,507 questions
39,218 answers
109,119 comments
36,600 users