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 = 0;
int j = 0;
for (i = 0; i < 4; i++)
{
for (j = 0; j < 3; j++)
{
if (i > 1)
continue;
Console.WriteLine(“Hi \n”);
}
}
Console.ReadLine();
}

What will be the output of the following C# code?
static void Main(string[] args)
{
int i = 0;
int j = 0;
for (i = 0; i < 4; i++)
{
for (j = 0; j < 3; j++)
{
if (i > 1)
continue;
Console.WriteLine(“Hi \n”);
}
}
Console.ReadLine();
}
a) Prints hi 4 times
b) Prints hi 3 times
c) Prints hi 6 times
d) Prints hi infinite times

Answer: c
Explanation: Output : hi
hi
hi
hi
hi
hi

Join The Discussion