Q:

Write a C# Sharp program to check a given integer and return true if it is within 10 of 100 or 200

0

Write a C# Sharp program to check a given integer and return true if it is within 10 of 100 or 200

Sample Output:

True
True
False

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;
namespace exercises
{
     class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(test(103));
            Console.WriteLine(test(90));
            Console.WriteLine(test(89));
            Console.ReadLine();
        }
      public static bool test(int x)
        {
              if(Math.Abs(x - 100) <= 10 || Math.Abs(x - 200) <= 10)
                return true;
            return false;
        }
  }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now