/* Scope.c */
#include <stdio.h>

int i = 3;    /* global variable */

void myfunction();

int main()
 {
  int j,k;    /* variables local to the main function */
	      /* j and k are not accessible outside of the main function */
  j = 2;
  k = i + j;
  printf("j = %d and k = %d\n", j, k);
  printf("i = %d before the call to myfunction.\n", i);
  myfunction(); /* call to myfunction */
  printf("i = %d after the call to myfunction.\n", i);
  return 0;
 }

void myfunction()
 {
  int l;      /* local variable */
  l = ++i;    /* the variable i is accessible because i is global */
	      /* the variable i is changed globally */
  printf("l = %d\n", l);
  printf("The variable l is lost as soon as myfunction exits.\n");
 }
