Yes. A while statement ends in a statement...
while (expression) statement
...and that statement can be a null statement, a single statement, or a block of statements. In the case of the block of statements, there is also a set of braces surrounding them...
while (expression);
while (expression) statement;
while (expression) {
statement1;
statement2;
...
statementN;
}
In the case where the body of the statement is null, there is no body. This is often done while taking advantage of side effects. For instance, to copy a string you could use...
char *strcpy (char *pszDestination, char *pszSource) {
char *pszTemp = pszDestination;
while ((*pszDestination++ = *pszSource++) != '\0');
return pszTemp;
}
...this works because the post-increment (++) operator has higher precedence than the dereference (*) operator, and because the assignment (=) operator has the value of the assignment, which is compared using the not equal (!=) operator against the string terminator null.
Note, carefully, the inner parentheses. They are needed because != has higher precedence than =, and you want it the other way around. Also, some compilers will let you eliminate the != '\0' terms and the inner parentheses, but that is not portable, and most compilers will warn you about assignment in a conditional expression.
In the case of a single statement you could use...
i= -1;
while (++i < argc) printf ("%d %s\n", i, argv[i]);
...here the while statement also ends in a semicolon.
The case of the block of statements is not shown, because it seems to be understood from the context of the question.
in C: a semicolon in itself. Examples:1. while (*to++ = *from++);2. { goto END; ... END:; }
It's the semicolon after the while ()part:i= 0;do printf ("%d %s\n", i, argv[i]); while (++i
For clasesses it defines from which class to inherit. :: means area of visibility in certain name space.
Semicolon, in some languages. Line-end in some others.
Every statement in java ends with a semi-colon ";"\The same is true with c and C++ however there are some things that do not require a ";" a "for" and "while" loop for example do not require it.
in C: a semicolon in itself. Examples:1. while (*to++ = *from++);2. { goto END; ... END:; }
It's the semicolon after the while ()part:i= 0;do printf ("%d %s\n", i, argv[i]); while (++i
No. That would be a syntax error. Only a right semicolon (;) can go at the end of a statement.
For clasesses it defines from which class to inherit. :: means area of visibility in certain name space.
Semicolon, in some languages. Line-end in some others.
Every statement in java ends with a semi-colon ";"\The same is true with c and C++ however there are some things that do not require a ";" a "for" and "while" loop for example do not require it.
semicolon ';' (Not applicable for block-statements)
A single semicolon standing alone does not form a complete statement.
When a statement is followed by a semicolon, this means that there is going to be another statement following the first statement which is related to it closely enough that it should not become a separate sentence.
Why semicolon? Tradition.What does it do? Terminates a single statement, eg:i+= 3; /* expression is a single statement */{ i= 3; --j; } /* no semicolon after the compound statement */
A semi-colon denotes the end of a statement. If you omit the semi-colon, the statement will extend into the next expression and this will result in a compiler error because a semi-colon will have been expected at the end of the first expression.
The computer language has a grammar for the syntax. Not all computer languages using ; to end a statement. The if-statements DO end with an ; (except when a <compound statement>) in C#, C, PHP, and Java (and many others). In fact, most of <statement> end with ; in those languages, and <if-statement> is just one of the derived <statement>. However, for statements like: if (1 == 2) {} else {}, the {} is a <compound statement> which does not end with a ; syntactically.