Question: using C# Loop Over Evens Complete the program on the left. Write a loop that displays the even numbers between x and y, smallest to
using C#
Loop Over Evens
Complete the program on the left.
Write a loop that displays the even numbers between x and y, smallest to largest. Include x and y if they are even.
Assume that x will be smaller than y. Zero is considered to be an even number.
Use Console.WriteLine to output each number.
You do not need to create the variables x and y or give them values. The tester will do this for you.
Your program will be tested multiple times using different values for the variables. To pass the challenge, all of the tests must succeed.
using System;
namespace LoopOverEvens
{
class Program
{
public void Run(int x, int y)
{
/** WRITE YOUR SOLUTION HERE **/
for (int i = x; i <= y; i++)
{
Console.WriteLine(i);
}
}
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
