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;
if (i == 0)
{
goto label;
}
label: Console.WriteLine(“HI…”);
Console.ReadLine();
}

What will be the output of the following C# code?
static void Main(string[] args)
{
int i = 0;
if (i == 0)
{
goto label;
}
label: Console.WriteLine(“HI…”);
Console.ReadLine();
}
a) Hi…infinite times
b) Code runs prints nothing
c) Hi Hi
d) Hi…

Answer: d
Explanation: for i = 0, if condition is satisfied as (i == 0). So, label statement is printed.
Output : Hi

Join The Discussion