This forum is now read-only. Please use our new forums! Go to forums

0 points
Submitted by Guilherme
almost 11 years

While Loop Syntax

How can I answer this exercise? I`m not understanding how is the while loop syntax! Could somebody help me?

Answer 515504c9c7bffe81830001a7

1 vote

Permalink

Is there a specific part of the syntax or the exercise that you are having trouble with?

points
Submitted by Devin West
almost 11 years

1 comments

Guilherme almost 11 years

Im with difficult to understand the syntax of the "While"(Im trying to solve the exercise 1.2)

Answer 515cc717e7d2c1cdbd000419

1 vote

Permalink

For exercise 1.2 you should not use the do/while loop syntax and instead you should use the while loop syntax

while(cond) {
   // looped statements go here
}

where the statements are executed as long as cond is true. Inside the loop body you should echo the string "<p>The loop is running.</p>".

points
Submitted by Devin West
almost 11 years

Answer 515c07404344b93d8d00150f

0 votes

Permalink

It would be helpful if you could post your code up! Then I can try see what’s wrong and add comments about what each line means :D

points
Submitted by James
almost 11 years

Answer 515c9ad2a8e2367e6900005e

0 votes

Permalink

<!DOCTYPE html>
points
Submitted by Guilherme
almost 11 years

1 comments

Devin West almost 11 years

The loop is not running outside of the curly braces { and } and there should also be a semicolon ; after while () statement in a do/while loop. But, the for this exercise you are not supposed to use a do/while loop. Please refer to my answer for more details.