In: Computer Science
I need this in C# with pseudocode
Exercise #2: Design and implement a programming (name it EvenOdd) that uses a while loop to determine and print out all even numbers between 50 and 100 on a single line, separated by commas. Then another while loop in the same program to print out all odd numbers between 50 and 100 on a new line, separated by commas. Document your code and properly label the outputs as shown below.
Even numbers between 50 and 100: 50, 52, 54, 56, 58, 60, 62, 64, …
Odd numbers between 50 and 100: 51, 53, 55, 57, 59, 61, 63, 65, …
using System;
class MainClass {
public static void Main (string[] args) {
// even numbers
int number = 50;
Console.Write("Even numbers between 50 and 100: " + number);
number += 2;
while(number <= 100) // while loop 1
{
Console.Write(", " + number);
number += 2;
}
// odd numbers
number = 51;
Console.Write("\n\nOdd numbers between 50 and 100: " +
number);
number += 2;
while(number <= 100) // while loop 2
{
Console.Write(", " + number);
number += 2;
}
}
}
/*OUTPUT
Even numbers between 50 and 100: 50, 52, 54, 56, 58, 60,62, 64, 66,
68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98,
100
Odd numbers between 50 and 100: 51, 53, 55, 57, 59, 61, 63, 65,
67, 69, 71, 73, 75, 77, 79, 81, 83, 85, 87, 89, 91, 93, 95, 97,
99
*/
// Hit the thumbs up if you are fine with the answer. Happy Learning!