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 + " ");
}
8 4 16 12 20
4 8 12 16 20
4 8 16 32 64
2 4 6 8 10
Answer: Option
Explanation:
No answer description is available. Let's discuss.
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


Post your comments here:

Your comments will be displayed after verification.