@Ralden
To write the code tags so others can see it, you type[[
b][/b]code][/code]
@BrendanKB
A do while is similar to a basic while, assuming you know how to do that. The syntax is this:
1 2 3
|
do {
code;
} while (expression);
|
When the code reaches a do while, it will always run the code, at least once, and if the expression is true, it will loop the code again, until the expression evaluates to false.
As for the if/else, it's hard to say without the exact code. The syntax is:
1 2 3 4 5 6 7 8
|
if (condition) {
// condition was true
code;
}
else {
// condition was false
code;
}
|
A common issue with beginner programmers is putting a semicolon directly after the if condition. I don't think that would cause an issue, unless you put a semi colon directly after the closing brace of the if block or have a semicolon before the block:
1 2 3 4 5 6 7 8
|
// Error can be generated from this
if (condition); {
code;
// or this
};
else {
code;
}
|
Edit: After seeing your code, I can see how you're misunderstanding the lecturer. The while should remain on the same line as the close brace for the do/while loop. This will prevent confusion. Also, do/whiles are the only conditional loops/statements that I know of that actually require a semicolon after it.