Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
8
Reply
Can't understand the result of one simple code
Mohamed Moubasher
Jan 31 2014 2:05 AM
1.3k
Reply
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.
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
8
)
Next Recommended Forum
online transaction on egopay through my website
cell number traking