Quiz #2

1. Using a while loop find the smallest positive integer whose square is larger than 15678.

int x = 1;

while (x * x <= 15678)
   x++;

Console.WriteLine("The smallest positive integer whose square is larger than 15678 is " + x);

 

2. Write a static method that takes two integer parameters and returns the string "Even" if both arguments are even, returns "Odd" if both arguments are odd, or returns "Mixed" in any other case.

static string EvenMixedOdd(int x,  int y) 
{
   if ((x % 2 == 0) && (y % 2 == 0))
      return "Even";

   if ((x % 2 != 0) && (y % 2 != 0))
      return "Odd";

   return "Mixed";
}