Welcome to Questionaries, where you can ask questions and receive answers from other members of the community.

Let us know at info@questionaries.org

What is Compound Statements?

9 like 0 dislike
Hi guys ,

          I am interested to know about Compound Statements.Have here any body who can help me.......................?
asked 1 year ago by biswaskeran (70,430 points)

2 Answers

1 like 0 dislike
A compound statement consists of none or more C++ statements enclosed within a set of braces: {}. It is an essential concept in C++ and is central to the idea of nesting constructs. For example, the if statement has the form:-
if ( expression ) statement
which would severely limit its use were it not for the fact that a compound statement is itself a statement. Consequently any number of statments can be enclosed within a set of braces, including other if and compound ones, and the resulting compound statement used with the if statement. For example:- if ( a > b ) { Float_t temp = b; b = a; a = temp; } See {..}
answered 1 year ago by marck_don (191,010 points)
2 like 0 dislike
Hi,Compound statements are statements that contain lists of statements enclosed in braces "{ statements }". See the following sections for examples.

    * The enclosed statements should be indented one more level than the compound statement.
    * The opening brace should be at the end of the line that begins the compound statement; the closing brace should begin a line and be indented to the beginning of the compound statement.
    * Braces are used around all statements, even single statements, when they are part of a control structure, such as a if-else or for statement. This makes it easier to add statements without accidentally introducing bugs due to forgetting to add braces.

Thanks,
answered 1 year ago by tulip (12,960 points)

Related questions

11 like 0 dislike
1 answer
12 like 0 dislike
1 answer
11 like 0 dislike
1 answer
9 like 0 dislike
1 answer
asked 1 year ago by lily (17,510 points)
10 like 0 dislike
1 answer
asked 1 year ago by biswaskeran (70,430 points)