Write a C# Sharp program to compute the sum of the two given integer values. If the two values are the same, then return triple their sum

  • برمجة سي شارب
  • برمجة

Write a C# Sharp program to compute the sum of the two given integer values. If the two values are the same, then return triple their sum

Sample Output:

3
5
12

الأجوبة

using System;
namespace exercises
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(test(1,2));
            Console.WriteLine(test(3,2));
            Console.WriteLine(test(2,2));
            Console.ReadLine();
        }

        public static int test(int x, int y)
        {
            return x == y ? (x + y)*3 : x + y;
        }
    }
}
هل كان المحتوى مفيد؟

تبحث عن مدرس اونلاين؟

محتاج مساعدة باختيار المدرس الافضل؟ تواصل مع فريقنا الان لمساعدتك بتأمين افضل مدرس
ماهو التخصص الذي تبحث عنه؟
اكتب هنا...