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