Please help me with the task: Sum calculator

Hello, I’m working on this task:

Write a program that outputs the sum of all even numbers between 150(including) and 250(not including).

Here is my code:


namespace ForLoops
{
   class EvenSum
   {
       static void Main(string[] args)
       {
           int sum = 0;
               for (int i= 149; i < 250; i=i+2)
               {
                  sum = sum + i;  
               }
       }
   }
}


Can anyone please help me to solve it?

Hi, there are 2 issues that I see in the code:

  • It’s not outputting the sum to the console
  • It’s summing odd numbers instead of even numbers.

Hope this helps!