A compound statement is any statement that is enclosed in curly braces, often referred to as a statement block. The entire block is treated as being a single statement, but is actually composed of none or more individual statements. Variables instantiated within a compound statement are local to the statement and fall from scope when the statement ends.
// Example of a simple statement:
for( int i=1; i<=10; ++i ) std::cout<<i<<std::endl;
// Example of a compound statement:
for( int i=1; i<=10; ++i ) {
int x=i*2;
std::cout<<x<<std::endl;
}
Compound statements may contain no statements at all. This is often encountered when using reverse logic:
if( x )
{} // compound statement
else
x=2;
The above is more typically written (and is easier to read) as a simple statement, as follows:
if( !x )
x=2;
A simple statement ends with a semi-colon (';'). A compound statement contains one or more simple statements (with semi-colon terminators) enclosed within opening and closing braces ('{' and '}').
The goto statement.
yes
d a tool for analysing c plus plus program
Every C plus plus program that is a main program must have the function 'main'.
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 simple statement ends with a semi-colon (';'). A compound statement contains one or more simple statements (with semi-colon terminators) enclosed within opening and closing braces ('{' and '}').
Yes, you can program games with C++.
The goto statement.
yes
Conditional execution. if (1==2) puts ("Wow, 1==2"); else puts ("No, 1<>2")
If statement is single selection statement,whereas the switch statement is multiple selective.
Exit the program and relaunch it.
d a tool for analysing c plus plus program
By learning how to program on C+.
C++ is an extension of C, and was invented by Bjarne Stroustrup.
a = b = c