Tech
Forums
Jobs
Books
Events
Videos
Conference
Annual Conference
Bcrypt
Ai Conference
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
15
Answers
code snippet ? functionality ??
Ask a question
Ask a question
Upload Source Code:
Select only zip and rar file.
SUNIL GUTTA
11y
1.3k
1
Reply
Hii
static void Main()
{
int i, j = 1, k;
for (i = 0; i < 5; i++)
{
k =j++ + ++j;
Console.WriteLine(k+" ");
}
Console.ReadKey();
}
In he above code .. i am getting out put as 4 8 12 16 20 ... well its compiler generated output it cant be wrong but the thing is i am confused .. with the block of code
K= j++ + ++J ;
Here acc to pre & post increment operation mechanism say initially j=1 next step j++ it remains 1 only after that ++j it gets 2 so 1+2 should be 3 but y am i getting 4 ..
Hope u got my point TY
Post
Reset
Cancel
Answers (
15
)
Next Recommended Forum
Try, Throw, Catch
How to code for GRidview shown content depends on id ?