Ex 36. Let X=10 and Y=6, evaluate the following boolean expression to true or false:
(X > 9 && (Y >= X || Y >= 6)
static void Main(string[] args)
{
int x = 10, y = 6;
bool b1 = (x > 9 && (y >= x || y >= 6));
Console.WriteLine("Boolean expression: {0}", b1);
Console.ReadLine();
}
//==============code for Question no 37==========================
Ex 37. Request and read four integer values V1, V2, V3, and V4. Subtract 5 from the highest value and display it. static void Main(string[] args)
{
Console.Write("Enter v1: ");
int v1 = int.Parse(Console.ReadLine());
Console.Write("Enter v2: ");
int v2 = int.Parse(Console.ReadLine());
Console.Write("Enter v3: ");
int v3 = int.Parse(Console.ReadLine());
Console.Write("Enter v4: ");
int v4 = int.Parse(Console.ReadLine());
int maxVal = 0;
if (v1 > v2 && v1 > v3 && v1 > v4)
{
maxVal = v1;
}
else if (v2 > v1 && v2 > v3 && v2 > v4)
{
maxVal = v2;
}
else if (v3 > v1 && v3 > v2 && v3 > v4)
{
maxVal = v3;
}
else if (v4 > v2 && v4 > v3 && v4 > v1)
{
maxVal = v4;
}
else
{
Console.WriteLine("Please enter 1 value for one time");
}
int result = maxVal - 5;
Console.WriteLine("Result: {0}", result);
Console.ReadLine();
}
}
}
No comments:
Post a Comment