answersLogoWhite

0


Best Answer

A compound statement is a code block. We typically use compound statements as the body of

another statement, such as a while statement:

while (i >= 0)

{

a[i] = x;

++x;

--i;

}

Note that all compound statements are surrounded by braces {}.

User Avatar

Wiki User

7y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

11y ago

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;

This answer is:
User Avatar

User Avatar

Wiki User

14y ago

I dont exactly know what you mean but int x = 2; is a statement...

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What is compound statement in c plus plus program?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Why the semicoloumn is used in c program?

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 */


What does a statement in c plus plus end with?

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 '}').


Can you program games with c plus plus?

Yes, you can program games with C++.


Which statement is not frequently used in C plus plus?

The goto statement.


Is C function a compound statement?

yes


What are the usage of IF statement in C plus plus program?

Conditional execution. if (1==2) puts ("Wow, 1==2"); else puts ("No, 1&lt;&gt;2")


What is the deffernce of the switch statement and the if statement in c plus plus?

If statement is single selection statement,whereas the switch statement is multiple selective.


How to restart c plus plus program?

Exit the program and relaunch it.


Lint is a compiler b a interactive debugger c a cinterpreter d a tool for analysing c plus plus program?

d a tool for analysing c plus plus program


How do you write a C plus plus program that will display the first 10 positive prime numbers?

By learning how to program on C+.


Where did C plus plus program come from?

C++ is an extension of C, and was invented by Bjarne Stroustrup.


How do you write a arithmetic operations in c using compound assignment statement?

a = b = c