Sunday, February 13, 2011

Using Loops

My one friend says that if u know one technical language its means u have cleared a concept of every language. so if u know C++ you also know C#.only the thing that makes them different is syntax and sementics.
 Program 1:
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int i;
            Console.WriteLine("this is loop console Application");

            Console.WriteLine("Press enter to go for loop");
            Console.ReadLine();
            for (i = 0; i < 5; i++)
            {
                Console.WriteLine(i);
            }
            Console.WriteLine("Press enter to go for do-while");
            Console.ReadLine();
           
            do
            {               
                Console.WriteLine(i);
                i++;

            }while(i<5);
            Console.WriteLine("Press enter to QUIT!!");
            Console.ReadLine();
               }
    }
}

Program 2:
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int i,j=0;
            Console.WriteLine("this is loop console Application");

            Console.WriteLine("Press enter to go for loop");
            Console.ReadLine();
            for (i = 0; i < 5; i++)
            {
                Console.WriteLine(i);
            }
            Console.WriteLine("Press enter to go for do-while");
            Console.ReadLine();
           
            do
            {               
                Console.WriteLine(j);
                j++;

            }while(j<5);
            Console.WriteLine("Press enter to QUIT!!");
            Console.ReadLine();
        }
    }
}
 Run both progams in VS and u can see the difference in their o/p's if u not understand the difference u can ask me!!!!!!!!

No comments:

Popular Posts