Sample – understanding life time and scope

by Nideesh C on February 8, 2011 · 0 comments

in C++




#include <iostream.h>

void f ();

int i = 0;

void main () {
cout << i << endl;
int i = 1;
cout << i << endl;
{
int i = 2;
cout << i << endl;
{
int i = 3;
cout << i << endl;
{
int i = 4;
cout << i << endl;
}
cout << i << endl;
}
cout << i << endl;
}
cout << i << endl;
f(); f(); f();
}

void f () {
cout << i << endl;
static int i = 5;
cout << i++ << endl;
}

Not Satisfied ? Just search & get the result

Related Posts Plugin for WordPress, Blogger...
Be Sociable, Share!

Related posts:

  1. Sample – understanding scope
  2. Sample – understanding call-by-value and call-by-reference
  3. Sample – convert temperatures
  4. Sample – compute square roots using Newton’s method
  5. Sample – compute distance between cities

Leave a Comment

Previous post:

Next post: