Tag Archive: Quiz


C# Pop Quiz

Look at this code:
int count = 0;

for(uint i = 10; i >=0; --i)
{
    ++count;
}

Console.WriteLine("Count is " + count);

What does it do?
...and don't compile it. That's cheating!

Advertisements

Neat little C++ trick

A colleague emailed me this neat little trick that made me snodchortle.

Look at this C++ code:


int a = 1;
int b = 2;

a ^= b;
b ^= a;
a ^= b;

What does this code do?

What are the values of a and b respectively at the end?

What are the benefits of this approach and what are the disadvantages?