C# Programming - Operators - Discussion
Discussion Forum : Operators - General Questions (Q.No. 16)
16.
What will be the output of the C#.NET code snippet given below?
int i, j = 1, k;
for (i = 0; i < 5; i++)
{
k = j++ + ++j;
Console.Write(k + " ");
}
Discussion:
11 comments Page 2 of 2.
Megha S said:
1 decade ago
i = 0, j = 1
k = 1 + 3 = 4
i = 1, j = 3
k = 3 + 5 = 8
i = 2, j = 5
k = 5 + 7 = 12
i = 3, j = 7
k = 7 + 9 = 16
i = 4, j = 9
k = 9 + 11 = 20
k = 1 + 3 = 4
i = 1, j = 3
k = 3 + 5 = 8
i = 2, j = 5
k = 5 + 7 = 12
i = 3, j = 7
k = 7 + 9 = 16
i = 4, j = 9
k = 9 + 11 = 20
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers