Dear Members,
I am a fresh beginner in programming just started few days ago, I am totally new!
While studying one of the examples about the integers (byte and int) I can't understand why it gives this result:
here is the code:
----------------------------------
// Use byte.
using System;
class Use_byte {
static void Main() {
byte x;
int sum;
sum = 0;
for(x = 1; x <= 100; x++)
sum = sum + x;
Console.WriteLine("Summation of 100 is " + sum);
}
}
-------------------------
the result is:
Summition of 100 is 5050
-----------------
Can anyone please explainstep by step why it shows 5050 and what is the logic of this code..
Thanks a lot.