Answer the question
In order to leave comments, you need to log in
Goto does not work in Pascal - why?
Continuing to write the program:
Program ferma;
var a: integer;
label 1, 2;
begin
a:=187;
1: if a=1 then goto 2;
if not Odd(a) then write (a/2) else write (a*3+1);
goto 1;
2: write(a);
end.
In response, it gives an infinite number of 562 - which is the reason for the question, because, since there is goto 1 below, it must repeat the condition of line 6, that is, divide 562 by 2. Why is this, what is connected with and what to do?
Answer the question
In order to leave comments, you need to log in
since there is goto 1 at the bottom, it must repeat the condition of line 6, that is, divide 562 by 2firstly, not 562 by 2, but the value of the variable
a
, that is, 187 by 2 what to do?to start write what you want to get in the end
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question