Select output for the following set of code:
static void Main(string[] args)
{
int I, J = 0;
for (I = 1; I < 10; ) ;
{
J = J + I;
I += 2;
}
Console.WriteLine("Sum of first 10 even numbers is:"+J);
Console.ReadLine();
}
1 2 3 4 5 6 7 8 9
25
1
Run time error
SHOW ANSWERSelect the output for the following set of code:
static void Main(string[] args)
{
int i, s = 0;
for (i = 1; i <= 10; s = s + i, i++);
{
Console.WriteLine(s);
}
Console.ReadLine();
}
Code report error
Code runs in infinite loop condition
Code gives output as 0 1 3 6 10 15 21 28 36 45
Code give output as 55
SHOW ANSWERSelect the output for the following set of code :
{
int i;
Console.WriteLine("Hi");
for (i = 1; i <= 10; i++)
Program.Main(args);
Console.ReadLine();
}
Prints ‘Hi’ for one time
Prints ‘Hi’ for infinite times
Stack overflow exception Condition generated
None of above mentioned
SHOW ANSWERSelect the output for the following set of code :
static void Main(string[] args)
{
int i, j;
for (i = 1, j = i; i <= 3 && j >= 0; i++, j--)
{
if (i == j)
continue;
else
Console.WriteLine(j);
}
Console.ReadLine();
}
i = 0, j = 1;
i = 1, j = 0;
j = 0;
None of the mentioned
SHOW ANSWER. Select the output for the following set of code :
static void Main(string[] args)
{
int i = -10;
for ( ;Convert.ToBoolean(Convert.ToInt32(i)) ;Console.WriteLine(i++)) ;
Console.ReadLine();
}
-9 -8 -7 -6 -5 -4 -3 -2 -1
-10 -9 -8 -7 -6 -5 -4 -3 -2
-10 -9 -8 -7 -6 -5 -4 -3 -2 -1
-8 -7 -6 -5 -4 -3 -2 -1
SHOW ANSWERSelect the output for the following set of code :
static void Main(string[] args)
{
int i, j;
for (i = 1; i <= 3; i++)
{
j = 1;
while (i % j == 2)
{
j++;
}
Console.WriteLine(i + " " + j);
}
Console.ReadLine();
}
11 21 31
1 12 13 1
11 21 31
1 1 2 1 3 1
SHOW ANSWERSelect the output for the following set of code:
static void Main(string[] args)
{
float s = 0.1f;
while (s <= 0.5f)
{
++s;
Console.WriteLine(s);
}
Console.ReadLine();
}
0.1
1.1
SHOW ANSWERWhat is the output of the following set of code ?
static void Main(string[] args)
{
int i, j;
int[, ] arr = new int[ 3, 3];
for (i = 0; i < 3; ++i)
{
for (j = 0; j < 3; ++j)
{
arr[i, j] = i * 2 + i * 2;
Console.WriteLine(arr[i, j]);
}
Console.ReadLine();
}
}
0,0,0 4,4,4 8,8,8
4,4,4 8,8,8 12,12,12
8,8,8 12,12,12 16,16,16
0,0,0 1,1,1, 2,2,2
SHOW ANSWERWhat is the output for the following set of code?
static void Main(string[] args)
{
char A = 'K';
char B = Convert.ToChar(76);
A++;
B++;
Console.WriteLine(A+ " " +B);
Console.ReadLine();
}
M L
U L
L M
A B
SHOW ANSWERWhich statement is correct about following c#.NET code ?
int[] a= {11, 3, 5, 9, 6};
‘a’ is a reference to the array created on stack
‘a’ is a reference to an object created on stack
‘a’ is a reference to an object of a class that compiler drives from ‘System.Array’ class
SHOW ANSWERWhich statement is correct about following set of code ?
int[, ]a={{5, 4, 3},{9, 2, 6}};
’a’ represents 1-D array of 5 integers
a.GetUpperBound(0) gives 9
’a’ represents rectangular array of 2 columns and 3 arrays
a.GetUpperBound(0) gives 2
SHOW ANSWERSelect the output for the following set of code :
static void Main(string[] args)
{
int i;
for (i = 0; ; )
{
Console.WriteLine("hello");
}
Console.ReadLine();
}
No output
hello
hello printed infinite times
Code will give error as expression syntax
SHOW ANSWERSelect the output for the following set of code:
static void Main(string[] args)
{
int i = 5;
for (; Convert.ToBoolean(Convert.ToInt32(i)); Console.WriteLine(i--)) ;
Console.ReadLine();
}
4 3 2 1
3 2 1
5 4 3 2 1
2 1
SHOW ANSWER