Q:

Write a C# Sharp program to check two given integers, and return true if one of them is 30 or if their sum is 30

0

Write a C# Sharp program to check two given integers, and return true if one of them is 30 or if their sum is 30

Sample Output:

True
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(30, 0));
            Console.WriteLine(test(25, 5));
            Console.WriteLine(test(20, 30));
            Console.WriteLine(test(20, 25));
            Console.ReadLine();
        }

      public static bool test(int x, int y)
        {
            return x == 30 || y == 30 || (x + y == 30);
        }
  }
}

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