|
In several places, the syntax of C++ requires a single statement. What if you want to write a sequence of statements where one statement is required? There is a syntactic trick for that. Any sequence of statements enclosed in curly braces is a single compound statement. For example,
{
printf("I am happy to meet you.\n");
printf("My name is Kim.\n");
}
looks to you like a sequence of two statements, but
is treated as one (compound) statement by a
C++ compiler.
For this course, follow these standards for compound statements:
|
According to rules (2) and (3),
{
printf("I am happy to meet you.\n");
printf("My name is Kim.\n");
}
is not correctly indented, and
{
printf("I am happy to meet you.\n");
printf("My name is Kim.\n");
}
is very poorly indented.
Indentation is neither complicated nor difficult. Follow examples. You can expect to lose points for each poorly indented line.
If you submit a program that is very poorly indented throughout, it is very difficult for me to read and you can expect to lose 50% of the available points for doing that.
|