Write a program in C# that reverses a collection and removes elements that are divisible by a given integer n. You will give the lower and upper limits for the range of elements and the integer n, like 1, 6, 2. Your output should be 5,3,1
/* * Program to print numbers from range low to up that are not divisible by n */ using System; public class Exercise2 { public static void Main() { int low, up, n; // retrieving n integers from the console Console.Write("Enter lower key: "); low = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter upper key: "); up = Convert.ToInt32(Console.ReadLine()); Console.Write("Enter n: "); n = Convert.ToInt32(Console.ReadLine()); Console.Write("\nOutput: "); for (int i = up; i >= low; i--) { if (i % n != 0) Console.Write(i + " "); } } } /* Program ends here */
Get Answers For Free
Most questions answered within 1 hours.