Block statement: { }, begin end
A compound statement is also known as block. to connect more than one statement in a statement, eventually reduces to a single command whole block of statements.{ }
Description
{}
{statement}
{statement statement}
Input
- statement - statements
Examples
Example
Block statement the possible of use:y=10;
if (x>1)
{
x=1;
y=y-1;
}
while (y>1)
{
x++;
y--;
}
Example
Other pieces of example codes:while (i<20) { i= i+2; if (i==16) { continue; } x++; }
if (i==10) break; else { i--; }
if (i==10) break; else { i--; }
do { i++; if (i==5) break; } while ( i <10);
repeat { i++; if (i==3) break; } until (i==10);
if (i > 10) { i =10; i = i - 1; i++; }
begin end
Description
begin end;
begin statement end;
begin statement statement end;
Input
- statement - code
Examples
Object Pascal
Block statement the possible of use:y:=10;
if x>1 then
begin
x:=1;
y:=y-1;
end;
while y>1 do
begin
inc(x);
dec(y);
end;
Object Pascal
Other pieces of example codes:while i<20 do begin i:= i+2; if i=16 then begin continue end; inc(x); end;
if i=10 then break else begin dec(i) end
if i > 10 then begin i :=10; i := i - 1; inc(i); end;
Block statement in another programming language: