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 i = 1, j = 2, k = 3;
do
{
Console.WriteLine((Convert.ToBoolean(Convert.ToInt32(i++)))
&& (Convert.ToBoolean(Convert.ToInt32(++j))));
}while (i <= 3);
Console.ReadLine();
}

What will be the output of the following C# code?
static void Main(string[] args)
{
int i = 1, j = 2, k = 3;
do
{
Console.WriteLine((Convert.ToBoolean(Convert.ToInt32(i++)))
&& (Convert.ToBoolean(Convert.ToInt32(++j))));
}while (i <= 3);
Console.ReadLine();
}
a) 0 0 0
b) True True True
c) 1 1 1
d) False False False

Answer: b
Explanation: 1 AND 1 = True. Similarly, non zero number || non zero number = True.
Output: True True True

Join The Discussion