What will be the output of the following C# code?
int i, j = 1, k;
for (i = 0; i < 3; i++)
{
k = j++ - ++j;
Console.Write(k + " ");
}
int i, j = 1, k;
for (i = 0; i < 3; i++)
{
k = j++ - ++j;
Console.Write(k + " ");
}
A. -4 -3 -2
B. -6 -4 -1
C. -2 -2 -2
D. -4 -4 -4
Answer: Option C
Related Questions on Operators and Expressions in C Sharp
What does the modulus operator (%) do in C#?
A. Increments the operand by 1
B. Returns the quotient of a division
C. Performs multiplication
D. Returns the remainder of a division
Join The Discussion