Code:
#include <iostream.h>
void main()
{
int x = 0; // Initialize the vars to zero
int y = 0;
// the NOT operator just means the oposite...since 0 can mean false and 1 can be mean true
// He's esentially saying "If x means true, make it mean false...if x means false, make it mean true"
// In this case, it means true, because it originally meant false
while(!x)
{
// Now he's trying to figure out, what x was originally
switch(x)
{
// If x was originally 0 (which, in this particular case it was do this...
case 0:
// He's now initializing x to 3 and decrementing it until it reaches 1
// esentially that is 3 times. And since y is never changed, it will
// output "yes" to the screen 3 times.
for(x=3;x>0;x--)
{
// he now wants to find out what y equals
switch(y)
{
// in this case y (look at top of page) equals 0 so the first one will output
case 0:
// "yes" will be output
cout<<"yes"<<endl;
break;
default:
cout<<"no"<<endl;
break;
}
}
// since y is NOT greater than 0, x does not get changed
if(y>0)
x = y;
break;
// this fails because x = 0;
case 1:
break;
// same here, x does not = 2;
case 2:
breal;
}
// y now equals 1
y++;
}
}
You can take the rest from there..that should give you some basic idea about how the code operates.