Quiz #1


1. Write a complete C# program that reads an integer from the user's console and if it is even prints the message "Yo, Adrian" and if it is odd prints the message "Yo-yo Ma".

using System;
namespace Quiz1_Prob1
{
   class Quiz1_Prob1 
   {
      static void Main(string[] args)
      {
         Console.Write("Enter an integer: ");
         int inp = int.Parse(Console.ReadLine());

         if (inp%2 == 0)
            Console.WriteLine("Yo, Adrian");
         else
            Console.WriteLine("Yo-yo Ma");
      }
   }
}
 

 

2. Write a complete C# program that assigns the variables x and y the values 22 and 19, respectively. Then print the result of computing x / y as (1) the integer quotient, (2) the integer remainder, and (3) the real number result. Provide appropriate headings for each.

using System;
namespace Quiz1_Prob2
{
   class Quiz1_Prob2 
   {
      static void Main(string[] args)
      {
         int x = 22, y = 19;

         Console.WriteLine("{0}/{1} = {2}", x, y, x / y);
         Console.WriteLine("{0}%{1} = {2}", x, y, x % y);
         Console.WriteLine("Real Result = ((double){0})/{1} = {2}", x , y, (double)x / y);
      }
   }
}