Question

# For the following questions, simply type your answer in the space provided with each question. Simply...

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++).

1. Rewrite the following pseudocode segment in C++ using the loop structures (for and while). Assume that all the variables are declared and initialized.

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;

}

.

..

.

#### Earn Coins

Coins can be redeemed for fabulous gifts.