C Statements and blocks.


C Statements and blocks.


Statements

C has three types of statement.
  • assignment
     =
    
  • selection (branching)
     if (expression)
     else
     switch
    
  • iteration (looping)
     while (expression)
     for (expression;expression;expression)
     do {block}
    

Blocks

These statements are grouped into blocks, a block is identified by curly brackets...There are two types of block.
                      Complete function example
    /************************************************************************ * * Purpose: Program to demonstrate functions. * Author: M J Leslie. * Date: 28-Feb-94 * ************************************************************************/ int add( int, int); /* Function declaration */ main() { int i=1; printf("i starts out life as %d.", i); i = add(1, 1); /* Function call */ printf(" And becomes %d after function is executed.\n", i); } /************************************************************************/ int add( int a, int b) /* Function definition */ { int c; c = a + b; return c; }

    Comments