Q:

Write a C# Sharp program to compute the sum of the two given integers. If one of the given integer value is in the range 10..20 inclusive return 18

0

Write a C# Sharp program to compute the sum of the two given integers. If one of the given integer value is in the range 10..20 inclusive return 18

Sample Output:

10
18
18
241

All Answers

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

using System;
using System.Linq;
namespace exercises
{
   class Program
    {        
        static void Main(string[] args)
        {
            Console.WriteLine(test(3, 7));
            Console.WriteLine(test(10, 11));
            Console.WriteLine(test(10, 20));
            Console.WriteLine(test(21, 220));
          
            Console.ReadLine();
        }
        public static int test(int x, int y)
        {
            return (x >= 10 && x <= 20) || (y >= 10 && y <= 20) ? 18 : x + y;
        }
    }
}

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