Lovemore Kutseya

Lovemore Kutseya

  • 1.8k
  • 21
  • 1.1k

( inclusive) output something if its within a range

Dec 17 2018 4:36 PM
should output Success if i is within 5 units of j (inclusive), but it doesn't work
 
using System;

namespace HelloWorld
{
class Program
{
static void Main(string[] args)
{
string output;
int i = 10;
int j = 10;

if ((i > j + 5) || (i > j - 5))
{
output = "Success";
}
else
{
output = "Failure";
}

Console.WriteLine(output);
}
}

Answers (2)