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;
for (i = 0; ; )
{
Console.WriteLine(“hello”);
}
Console.ReadLine();
}

What will be the output of the following C# code?
static void Main(string[] args)
{
int i;
for (i = 0; ; )
{
Console.WriteLine(“hello”);
}
Console.ReadLine();
}
a) No output
b) hello
c) hello printed infinite times
d) Code will give error as expression syntax

Answer: c
Explanation: Testing condition for the loop is absent. So, loop will continue executing.
Output : hello
hello
hello
.
.
.

Join The Discussion