Q:

Why am I getting different results when using for and while loops?

Why am I getting different results when using for and while loops?
for (int i = 1; i < 100; i*= 2)
{
    Console.Write(i);
}

//1248163264

. 
int i = 1;
while (i < 100)
{
    i *= 2;
    Console.Write(i);
}

//248163264128

A:

Because while statement executes your Console.Write(128) first and then checks it if i (which is 128 in this case) is less than 100 or not.
if you use Console.Write(i); before you multiple it, you will get the same result because in this case it writes your 64 value first then multiple by 2 and since 128 < 100 returns false, it will not execute in your while statement anymore.
int i = 1;
while (i < 100)
{
    Console.Write(i);
    i *= 2;
} // 1248163264

Read 8.8.1 The while statement

A while statement is executed as follows:

The boolean-expression (Section 7.16) is evaluated.
If the Boolean expression yields true, control is transferred to the embedded statement. When and if control reaches the end point of
  the embedded statement (possibly from execution of a continue
  statement), control is transferred to the beginning of the while
  statement.
If the Boolean expression yields false, control is transferred to the end point of the while statement.

A:

In the for loop the condition is checked each time after the step (i *= 2) is evaluated.Since it evalutes to false when i becomes 128, the loop ends.
But in while, your Console.WriteLine is executed before the check.So that's why it outputs one extra number...

