Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the following C# code?
static void Main(string[] args)
{
int a = 5;
int b = 10;
int c;
Console.WriteLine(c = ++ a + b ++);
Console.WriteLine(b);
Console.ReadLine();
}

What will be the output of the following C# code?
static void Main(string[] args)
{
int a = 5;
int b = 10;
int c;
Console.WriteLine(c = ++ a + b ++);
Console.WriteLine(b);
Console.ReadLine();
}
a) 11, 10
b) 16, 10
c) 16, 11
d) 15, 11

Answer: c
Explanation: c = 6 + 10 = 16 and b = 11 as we know ++operator increments and then executes similarly operator++ executes and then increments.

Join The Discussion