‹header›
‹date/time›
Click to edit Master text styles
Second level
Third level
Fourth level
Fifth level
‹footer›
‹#›
This program will not compile because the
compiler will detect that there is no such variable as x by the time the cout
occurs.
This code is fine because the variable y
exists until the matching brace, which is at the end of the program after the
cout << y << endl;
This code is fine because the variable y
exists until the matching brace, which is at the end of the program after the
cout << y << endl;
This code is fine because the variable y
exists until the matching brace, which is at the end of the program after the
cout << y << endl;
This code is fine because the variable y
exists until the matching brace, which is at the end of the program after the
cout << y << endl;
This code is fine because the variable y
exists until the matching brace, which is at the end of the program after the
cout << y << endl;
This code is fine because the variable y
exists until the matching brace, which is at the end of the program after the
cout << y << endl;
This code is fine because the variable y
exists until the matching brace, which is at the end of the program after the
cout << y << endl;
x = 2. x = 1
File and class scope we will encounter when we get to object oriented
programming
Global variables are a holdover from C. They are strongly discouraged since
they lead to spaghetti code where the flow of execution becomes very
difficulty to follow.
Static variables are not destroyed when their scope ends.
x = 2. x = 1
x = 2. x = 1
x = 2. x = 1
x = 2. x = 1
x = 2. x = 1
First of all does n = n + 1 make sense to everyone?
Code on the left prints the integers from 0 to 14
What about n = 0; 0! Should be 1
What does the program on the right print when n= 0?
x = 2. x = 1
x = 2. x = 1
Programming
is a science and a craft. The craft aspect results in programmers using idioms in there code. Certain
algorithms are performed in certain ways
because that is the way everyone does it. The
use of for loops is one such idiom. Idioms can be useful because it becomes easy to recognize the intention of a
piece of code someone else has written
even before you fully understand it.