Tuesday, March 30, 2010

Can you guess the result?

Let's see

// example 1
int i =0;
int nResult =0;
for (i=0; i<100, i<0; i++)
{
nResult += i;
}
What is the result value of nResult?

// example 2
int i =0;
int nResult =0;
for (i=0; i<0, i<100,; i++)
{
nResult += i;
}
What is the result value of nResult?

Can you guess the result without compile of thoes code?

The answers are
example 1: nResult = 0
example 2: nResult = 4950

Your guess is right?

No comments: