1. using System; namespace Exam1 { public class Qestion1 { public static void Main() { Console.WriteLine("Please input two intergers:"); int a = int.Parse(Console.ReadLine()); int b = int.Parse(Console.ReadLine()); Console.WriteLine("a * b = {0}",a*b); Console.WriteLine("a / b = {0}",a/b); Console.WriteLine("a - b = {0}",a-b); Console.WriteLine("a + b = {0}",a+b); Console.WriteLine("a % b = {0}",a%b); } } } 2. Call-by-value passes copying values. So the method won’t change the values of the variables passed in. Call-by-reference passes copying reference which refers to the memory location. So it can change the value of the variable passed into the method. 3. A value type stores a variable's value in the memory location. Value types in C# include: 1)Primitive data types (byte, sbyte, short, ushort, int, uint,long, ulong, float,double, char,&boolean) 2)Structures & 3)Enumerations. A reference type is known by a reference, that is, a memory location that stores the address where the object resides in memory. _________________ _________________ _____________ | | | | | | |A value | | | | | |(int, char, bool,| |A memory address-|------>| | | double,... | | | | | |_________________| |_________________| |_____________| (a) A value type (b) A reference type 4. C# allows you to define different versions of a method in class, and the compiler will automatically select the most appropriate one based on the parameters supplied. public int Sum(int a, int b) { int c = a+b; return c; } public double Sum(double a, double b) { double c = a+b; return c; } 5. Console.WriteLine("Please input an integer:"); int x = int.Parse(Console.ReadLine()); int cube = x*x*x; if(cube >= 10 && cube <= 150) { Console.WriteLine("You are a winner"); } else { Console.WriteLine("Sorry, you didn't win this time"); } 6. using System; namespace Exam1 { public class Qestion6 { public static void Main() { int sum = 0; for(int val = 1; val <= 51; val += 2) { sum += val; } Console.WriteLine("Sum of odd numbers from 1 to 51 is {0}", sum); } } } 7. int input; do { Console.WriteLine("Please input an EVEN POSITIVE integer:"); input = int.Parse(Console.ReadLine()); }while(input%2 == 1 || input < 0); 8. public static bool StrangeOdd(int x) { int y = (x-3)*(x-2); bool result; if(y%2 == 1) result = true; //y is odd else result = false; //y is even return result; }