Tuesday, 28 April 2015

//This program demonstrates the 'continue' statement
namespace ProfTyagi
{
    class democontinue
    {
        static void Main(string[] args)
        {
            int y = 0;
            for (int x = 1; x < 12; x++)
            {
                Console.WriteLine("x = " + x);
                Console.WriteLine("y = " + y);
                if ((x % 7) == 0)
                    continue;
                y++;
            }
            Console.WriteLine("Have you noticed the effect of continue");
        }
    }
}



Monday, 27 April 2015

//Program to illustrate break statement

namespace ProfTyagi
{
    class demobreak
    {
        static void Main(string[] args)
        {
            int a = 0;
            while (a < 10)
            {

                Console.WriteLine(a);
                a++;
                if (a == 5)
                    break;
            }
            Console.WriteLine("You have seen that as 'a' becomes 5 it comes out of while though vcondition is true at while test");
        }
    }
}