Write a C# program to compute the sum of two given integers, if two values are equal then return the triple of their sum

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

Write a C# program to compute the sum of two given integers, if two values are equal then return the triple of their sum

Sample Output:

12                                                                     
22                                                                     
-3

الأجوبة

using System;
using System.Collections.Generic;

public class Exercise19 {
  static void Main(string[] args)
        {
            Console.WriteLine(SumTriple(2,2));
            Console.WriteLine(SumTriple(12,10));
            Console.WriteLine(SumTriple(-5,2));          
        }
        public static int SumTriple(int a, int b)
        {
            return a == b ? (a + b)*3 : a + b;
        }
}
هل كان المحتوى مفيد؟

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

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