Test 1


Program 1
using System;


namespace Hello
{
    class Program
    {
        static void Main()
        {
            Console.WriteLine("Hello, World ");
            Console.WriteLine("Computer Programing");
            Console.ReadLine();
        }
    }
}




Program 2
using System;


namespace DemoEscapeSquences {

    class Program{
        static void Main() {
       
            Console.WriteLine("This Line \tcontains two \ttabs ");
            Console.WriteLine("This statement\ncontains a new line");
            Console.WriteLine("This statement sound three alerts\a\a\a");
            Console.ReadLine();
        }
    }
}






Program 4.1



using System;


namespace IntegerRange{
    class Program{
        static void Main(){
            Console.WriteLine("min sbyte = " +SByte.MinValue);
            Console.WriteLine("max sbyte = " +SByte.MaxValue);
            Console.WriteLine("min byte = " +Byte.MinValue);
            Console.WriteLine("max byte = " +Byte.MaxValue);
            Console.WriteLine("min short = " +Int16.MinValue);
            Console.WriteLine("max short = " +Int16.MaxValue);
            Console.WriteLine("min ushort = " +UInt16.MinValue);
            Console.WriteLine("max ushort = " +UInt16.MaxValue);
            Console.WriteLine("min int =" + Int32. MinValue);
            Console.WriteLine("max int =" + Int32. MaxValue);
            Console.WriteLine("min uint =" + UInt32. MinValue);
            Console.WriteLine("max uint =" + UInt32. MaxValue);
            Console.WriteLine("min long =" + Int64. MinValue);
            Console.WriteLine("max long =" + Int64. MaxValue);
            Console.WriteLine("min ulong =" +UInt64. MinValue);
            Console.WriteLine("max ulong =" +UInt64. MaxValue);
            Console.ReadLine();
        }
    }
}






Program 4.2


using System;


namespace DisplaySomeMoney {
    class Program{
        static void Main(){
            double someMoney = 39.45;
            Console.Write("The money is");
            Console.WriteLine(someMoney);
            double someMoney1 = 39.46;
            Console.Write("The money is");
            Console.WriteLine(someMoney1);
            double someMoney2 = 39.47;
            Console.Write("The money is");
            Console.WriteLine(someMoney2);
            double someMoney3 = 39.48;
            Console.Write("The money is");
            Console.WriteLine(someMoney3);
            double someMoney4 = 39.49;
            Console.Write("The money is");
            Console.WriteLine(someMoney4);
            double someMoney5 = 39.50;
            Console.Write("The money is");
            Console.WriteLine(someMoney5);
            Console.ReadLine();
        }
    }
}




Program 4.4



using System;


namespace Relational{

    class Program{
        static void Main(string[] args){
            int x = 17;
            int y = 5;
            Console.WriteLine("{0} == {1} = {2}", x,y,x == y);
            Console.WriteLine("{0}! = {1} = {2}", x,y,x != y);
            Console.WriteLine("{0} < {1} = {2}", x,y,x < y);
            Console.WriteLine("{0} <= {1} = {2}", x,y,x <= y);
            Console.WriteLine("{0} > {1} = {2}", x,y,x > y);
            Console.WriteLine("{0} >= {1} = {2}", x,y,x >= y);
            Console.ReadLine();
        }
    }
}




Program 4.5


using System;


namespace ShortCircuit{
    class Program{
        static void Main(string[] args){
            int x = 4;
            int y = 5;
            Console.WriteLine("x = {0}, y = {1}", x, y);
            bool result = true ||  (++x == y);
            Console.WriteLine("result = {0}",result);
            Console.WriteLine("x = {0}, y = {1}", x, y);

            result = true && (++x == y);
            Console.WriteLine("result = {0}",result);
            Console.WriteLine("x = {0}, y = {1}", x, y);
            Console.ReadLine();
        }
    }
}