The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
+3 votes
1.8k 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 Loyal (6.2k points) | 1.8k views

2 Answers

+8 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 Boss (18.3k points)
selected by
0
Why it wont increase time?Wont it create stalls in assembly language code?
+2
@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?
0
@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
0

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

0
@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
0

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 ?

0
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
answered by (11 points)

Related questions

0 votes
1 answer
1
asked May 8, 2015 in Programming by Rahul Kumar 1 (9 points) | 381 views


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

44,276 questions
49,767 answers
164,264 comments
65,853 users