Q:

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

0

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

Sample Output:

29
30
39
30

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(12, 17));
            Console.WriteLine(test(2, 17));
            Console.WriteLine(test(22, 17));
            Console.WriteLine(test(20, 0));
            Console.ReadLine();
        }
        public static int test(int a, int b)
        {
            return a + b >= 10 && a + b <= 20 ? 30 : a + b;
        }

    }
}

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