1.1k views

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)}$
edited | 1.1k views
0
What is the difference between forward goto and arbitrary goto ?
+1
Need further clarifications of the question, in simpler words.
–1
Please clarify why point (ii) for loops where the loop parameter cannot be changed within the loop.............can be included.
0
@ arjun sir plz explain this

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 (3.2k points)
edited
0
int a =5;

while (a)

{

a--;

--a;

}

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

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

when we get while(0) it will terminate. rt?
0
can someone plz explain the option more clearly ... ?
+1
Please explain why point (ii) for loops where the loop parameter cannot be changed within the loop.............can be included.
0
What is the difference between forward and arbitrary goto?
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.5k points)
0
but if arbitrary goto can cause looping?

Can u give some example?
0
The example in the last of my answer shows that arbitrary goto can cause loop. @srestha
0
how r u say it arbitrary?
+2
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?
0
yes

but then forward goto also has an option
+2
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.

Hi @Arjun Sir and every one , i think

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

A()

{

B()

}

B()

{

A()

}

answered by Active (1.5k points)
0
Can u explain what statement 2 means?
0
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.