52. Arrange the operators in the increasing order as defined in C#.
!=, ?:, &, ++, &&
!=, ?:, &, ++, &&
53. What will be the output of the following C# code?
public static void Main()
{
byte varA = 10;
byte varB = 20;
long result = varA | varB;
Console.WriteLine("{0} OR {1} Result :{2}", varA, varB, result);
varA = 10;
varB = 10;
result = varA | varB;
Console.WriteLine("{0} OR {1} Result : {2}", varA, varB, result);
}
public static void Main()
{
byte varA = 10;
byte varB = 20;
long result = varA | varB;
Console.WriteLine("{0} OR {1} Result :{2}", varA, varB, result);
varA = 10;
varB = 10;
result = varA | varB;
Console.WriteLine("{0} OR {1} Result : {2}", varA, varB, result);
}
54. What will be the output of the following C# code?
static void Main(string[] args)
{
int a, b, c, x;
a = 90;
b = 15;
c = 3;
x = a - b / 3 + c * 2 - 1;
Console.WriteLine(x);
Console.ReadLine();
}
static void Main(string[] args)
{
int a, b, c, x;
a = 90;
b = 15;
c = 3;
x = a - b / 3 + c * 2 - 1;
Console.WriteLine(x);
Console.ReadLine();
}
55. What will be the output of the following C# code?
static void Main(string[] args)
{
float a = 16.4f;
int b = 12;
float c;
c = a * ( b + a) / (a - b) ;
Console.WriteLine("result is :" +c);
Console.ReadLine();
}
static void Main(string[] args)
{
float a = 16.4f;
int b = 12;
float c;
c = a * ( b + a) / (a - b) ;
Console.WriteLine("result is :" +c);
Console.ReadLine();
}
56. Check the following C# code whether the given relation operator works according to the if condition or not.
static void Main(string[] args)
{
int a = 10;
int b = 5;
int c = 12;
int e = 8;
int d;
d = Convert.ToInt32((a * (c - b) / e + (b + c)) <= (e * (c + a) / (b + c) + a));
Console.WriteLine(d);
if (d == 1)
{
Console.WriteLine("C# is great language!");
Console.WriteLine((a * (c - b) / e + (b + c)));
}
else
{
Console.WriteLine("harsh is not great language!");
Console.WriteLine((e * (c + a) / (b + c) + a));
}
}
static void Main(string[] args)
{
int a = 10;
int b = 5;
int c = 12;
int e = 8;
int d;
d = Convert.ToInt32((a * (c - b) / e + (b + c)) <= (e * (c + a) / (b + c) + a));
Console.WriteLine(d);
if (d == 1)
{
Console.WriteLine("C# is great language!");
Console.WriteLine((a * (c - b) / e + (b + c)));
}
else
{
Console.WriteLine("harsh is not great language!");
Console.WriteLine((e * (c + a) / (b + c) + a));
}
}
57. What will be the output of the following C# code?
public static void Main(string[] args)
{
int a = 4;
int c = 2;
bool b = (a % c == 0 ? true : false);
Console.WriteLine(b.ToString());
if (a/c == 2)
{
Console.WriteLine("true");
}
else
{
Console.WriteLine("false");
}
Console.ReadLine();
}
public static void Main(string[] args)
{
int a = 4;
int c = 2;
bool b = (a % c == 0 ? true : false);
Console.WriteLine(b.ToString());
if (a/c == 2)
{
Console.WriteLine("true");
}
else
{
Console.WriteLine("false");
}
Console.ReadLine();
}
58. What will be the output of the following C# code?
static void Main(string[] args)
{
int a = 3, b = 5, c = 1;
int z = ++b;
int y = ++c;
b = Convert.ToInt32((Convert.ToBoolean(z)) && (Convert.ToBoolean(y))
|| Convert.ToBoolean(Convert.ToInt32(!(++a == b))));
a = Convert.ToInt32(Convert.ToBoolean(c) || Convert.ToBoolean(a--));
Console.WriteLine(++a);
Console.WriteLine(++b);
Console.WriteLine(c);
}
static void Main(string[] args)
{
int a = 3, b = 5, c = 1;
int z = ++b;
int y = ++c;
b = Convert.ToInt32((Convert.ToBoolean(z)) && (Convert.ToBoolean(y))
|| Convert.ToBoolean(Convert.ToInt32(!(++a == b))));
a = Convert.ToInt32(Convert.ToBoolean(c) || Convert.ToBoolean(a--));
Console.WriteLine(++a);
Console.WriteLine(++b);
Console.WriteLine(c);
}
59. What will be the output of the following C# code?
static void Main(string[] args)
{
int a = 8, b = 6, c = 10;
int d = a * c * 2 / Convert.ToInt32(Math.Pow ((c - b), 2));
if (d == (c = Convert.ToInt32(Math.Sqrt (a * a + b * b))) && c == 10)
{
Console.WriteLine("figure is hypotenuse");
}
else
{
Console.WriteLine("figure is square");
}
}
static void Main(string[] args)
{
int a = 8, b = 6, c = 10;
int d = a * c * 2 / Convert.ToInt32(Math.Pow ((c - b), 2));
if (d == (c = Convert.ToInt32(Math.Sqrt (a * a + b * b))) && c == 10)
{
Console.WriteLine("figure is hypotenuse");
}
else
{
Console.WriteLine("figure is square");
}
}
60. What will be the output of the following C# code?
static void Main(string[] args)
{
int n = 5;
int x = 4;
int z, c, k;
for (c = 1; c <= n; c++)
{
for (k = 1; k <= c; k++)
{
z = 3 * x * x + 2 * x + 4 / x + 8;
Console.Write(Convert.ToString(Convert.ToChar(z)));
}
Console.WriteLine("\n");
}
Console.ReadLine();
}
static void Main(string[] args)
{
int n = 5;
int x = 4;
int z, c, k;
for (c = 1; c <= n; c++)
{
for (k = 1; k <= c; k++)
{
z = 3 * x * x + 2 * x + 4 / x + 8;
Console.Write(Convert.ToString(Convert.ToChar(z)));
}
Console.WriteLine("\n");
}
Console.ReadLine();
}