42. Which operator is used to perform inequality comparison in C#?
43. Correct order of priorities are:
44. What will be the output of the following C# code?
static void Main(string[] args)
{
int a = 4;
int b = 5;
int c = 6;
int d = 8;
if (((a * b / c) + d) >= ((b * c + d ) / a))
{
Console.WriteLine("Line 1 - a is greater to b");
Console.WriteLine((a * b / c) + d);
}
else
{
Console.WriteLine("Line 1 - a is not greater to b");
Console.WriteLine((b * c + d )/ a);
}
}
static void Main(string[] args)
{
int a = 4;
int b = 5;
int c = 6;
int d = 8;
if (((a * b / c) + d) >= ((b * c + d ) / a))
{
Console.WriteLine("Line 1 - a is greater to b");
Console.WriteLine((a * b / c) + d);
}
else
{
Console.WriteLine("Line 1 - a is not greater to b");
Console.WriteLine((b * c + d )/ a);
}
}
45. Which among the following is a conditional operator?
46. What will be the output of the following C# code?
static void Main(string[] args)
{
byte varA = 10;
byte varB = 20;
long result = varA & varB;
Console.WriteLine("{0} AND {1} Result :{2}", varA, varB, result);
varA = 10;
varB = 10;
result = varA & varB;
Console.WriteLine("{0} AND {1} Result : {2}", varA, varB, result);
Console.ReadLine();
}
static void Main(string[] args)
{
byte varA = 10;
byte varB = 20;
long result = varA & varB;
Console.WriteLine("{0} AND {1} Result :{2}", varA, varB, result);
varA = 10;
varB = 10;
result = varA & varB;
Console.WriteLine("{0} AND {1} Result : {2}", varA, varB, result);
Console.ReadLine();
}
47. What will be the output of the following C# code?
m = 5;
int y;
1. y = m++;
2. y = ++m;
m = 5;
int y;
1. y = m++;
2. y = ++m;
48. Select the relevant C# code set to fill up the blank for the following C# program?
static void Main(string[] args)
{
int x = 10, y = 20;
int res;
/*_______________*/
Console.WriteLine(res);
}
static void Main(string[] args)
{
int x = 10, y = 20;
int res;
/*_______________*/
Console.WriteLine(res);
}
49. What will be the output of the following C# code?
static void Main(string[] args)
{
int m = 10, n = 5, p = 20;
bool b1 = m * p / n <= p * n / m ;
int l = p - 2 * m;
bool b2 = l == 0;
int z = Convert.ToInt32(b2);
int k = Convert.ToInt32(b1);
Console.WriteLine(k);
Console.WriteLine(z);
}
static void Main(string[] args)
{
int m = 10, n = 5, p = 20;
bool b1 = m * p / n <= p * n / m ;
int l = p - 2 * m;
bool b2 = l == 0;
int z = Convert.ToInt32(b2);
int k = Convert.ToInt32(b1);
Console.WriteLine(k);
Console.WriteLine(z);
}
50. What will be the output of the following C# code?
static void Main(string[] args)
{
int y = 5;
int x;
int k = (!(Convert.ToInt32(y) > 10))? x = y + 3 : x = y + 10;
Console.WriteLine(x);
Console.WriteLine(y);
Console.ReadLine();
}
static void Main(string[] args)
{
int y = 5;
int x;
int k = (!(Convert.ToInt32(y) > 10))? x = y + 3 : x = y + 10;
Console.WriteLine(x);
Console.WriteLine(y);
Console.ReadLine();
}