The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
+14 votes

Given the programming constructs

  1. assignment
  2. for loops where the loop parameter cannot be changed within the loop
  3. if-then-else
  4. forward go to
  5. arbitrary go to
  6. non-recursive procedure call
  7. recursive procedure/function call
  8. repeat loop,

which constructs will you not include in a programming language such that it should be possible to program the terminates (i.e., halting) function in the same programming language

  1. $\text{(ii), (iii), (iv)}$
  2. $\text{(v), (vii), (viii)}$
  3. $\text{(vi), (vii), (viii)}$
  4. $\text{(iii), (vii), (viii)}$
asked in Programming by Veteran (52.1k points)
edited by | 1.6k views
What is the difference between forward goto and arbitrary goto ?
Need further clarifications of the question, in simpler words.
Please clarify why point (ii) for loops where the loop parameter cannot be changed within the loop.............can be included.
@ arjun sir plz explain this

3 Answers

+18 votes

Answer is (B).

Arbitary goto,recursive call and repeat may enter infinite loop,and hence terminates program may not be able to answer if 'the program does terminate'.

answered by Active (2.9k points)
edited by
int a =5;

while (a)





here also we wont be able to terminate our program ryt ?

so answer may diifer ?
@Dexter why here program not terminate?

when we get while(0) it will terminate. rt?
can someone plz explain the option more clearly ... ?
Please explain why point (ii) for loops where the loop parameter cannot be changed within the loop.............can be included.
What is the difference between forward and arbitrary goto?
please explain option ii)

@prachigupta let current instruction is at 5 then in the forward goto we can go to  any instruction no greater then 5

but in arbitrary go to we can go to any instruction ex. 4,8,2 etc from instruction 5

+8 votes
Eliminating options:-

Looking at the given list,7 and 8 will definitely in the answer so we can eliminate option 1 on this base.

Now we are left with 2,3,4 option.In which 2 items 7,8 are there in every option.So we just need to check 5,6,3 to get the answer.

If-else is just a block of constant set of statements,hence it cannot will not cause any looping.

Also,,Non recursive procedure call will not cause any looping in the program.

Now arbitrary goto can cause looping.Assume i have following code:-

LABEL:- statement 1

              statement 2

            GOTO LABEL. // Loop infinite

So based on this we can conclude b is the correct answer.
answered by Boss (24.4k points)
but if arbitrary goto can cause looping?

Can u give some example?
The example in the last of my answer shows that arbitrary goto can cause loop. @srestha
how r u say it arbitrary?
arbitary means randomly which means goto can be placed anyhwere.Now someone can place it the way i did or some other way(which lead to infinite loop).

We have also selected recursion in the given answer.Now that does not mean that every recursion will stop the program from termintaion.Recursive program may or may not goto infinite loop.But as in the question,we need the program to terminate so we will not allow recursion.

Same for GOTO.Presence of GOTO means some probability(not always) of going into infinite loop as mentioned in the answer.

If i don't select goto in the answer it means that GOTO can never take program to infinite loop.But it is false statement.So GOTO should be in the answer.

Does this make sense now?

but then forward goto also has an option
I have eliminated option 1 which has forward GOTO as mentioned in answer.

I am not sure by forward GOTO but as per name it means it can go in forward direction.So it cannot goto infinite loop.Becasue if it always go in forward direction then at sometime we will approach program end.Either by executing program sequentially or jumping forward.

But arbitary as i said means random so it might be possible for GOTO to go forward and backward.

P.S;- I have looked for forward goto in google but does not find any information.

mam i think arbitrary goto is a part of continuation heading in this link


@rahul sharma 5  plz explain this stmt

for loops where the loop parameter cannot be changed within the loop

0 votes

Hi @Arjun Sir and every one , i think 

  1. non-recursive procedure call can also create non terminating program 









answered by Active (4.4k points)
Can u explain what statement 2 means?
If you think like this then each and every option in the question may lead to program execution non-terminating in some way or another. But v, vii, viii have the highest chance to make it run infinitely, so, they're the answers.

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
49,811 questions
54,533 answers
75,554 users