Tuesday, March 18, 2014

Do_While_Loop_Ex_1 (Wk-7) Feb 17-21, 2014

Exercise 1: Add all the integers values from 150 to 175 using the do-while loop.

        static void Main(string[] args)
        {
            int counter = 150;
            int sum = 0;
            do
            {
                sum += counter;
                Console.WriteLine("counter = {0}   sum = {1}", counter, sum);
                counter++;

            } while (counter <= 175);
            Console.ReadLine();
        }

No comments:

Post a Comment