Block (programming)

This is an old revision of this page, as edited by Aecarol (talk | contribs) at 18:13, 2 June 2004 (Added mention that other languages use "begin" and "end" to denote blocks). 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 {}. In Ada, Pascal, and some other languages, blocks are denoted by "begin" and "end" statements. 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;
}