Exercise 1: Add all the int values between 1 and 10.
static void Main(string[] args)
{
int sum = 0;
for (int counter = 1; counter <= 10; counter++)
{
sum += counter;
Console.WriteLine("Counter: {0} Sum: {1}", counter, sum);
}
Console.ReadLine();
}
No comments:
Post a Comment