Block (programming)

This is an old revision of this page, as edited by Dysprosia (talk | contribs) at 23:46, 29 November 2003 (un c++-ify, make it more general). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

In computer programming, a statement block is a section of code which is grouped together, much like a paragraph; such blocks consist of one, or more, statements. In C, C++, and some other languages, statement blocks are enclosed by braces {}. Unlike paragraphs, statement blocks can be nested; that is, with one block inside another.

A typical statement block

int main()
{
  return 0;
}

A nested statement block

int main()
{
  int x=1;
  if(x==1)
  {
     x++;
  }
  return 0;
}