For the following questions, simply type your answer in the space provided with each question. Simply translate the provided code segment in the specified language (C++).
k = (j + 13) / 27
loop:
if k > 10 then goto out
k = k + 1
i = 3 * k - 1
goto loop
out: . . .
Ans
In while loop:-
initialize;
while(loop condition){
statement;
flow statement;
}
in for loop:-
for(initialize; loop condition;flow){
statement;
}
Here loop condition is !(k>10) because when k>10 it comes out. flow statement k=k+1;
.
Using while:-
code:-
k=(j+13)/27;
while(!(k<10)){
k=k+1;
i=3*k-1;
}
..
.
Using for:-
code:-
for(k=(j+13)/27;!(k<10);k++){
i=3*k-1;
}
.
..
.
If any doubt ask in the comments.
Get Answers For Free
Most questions answered within 1 hours.