Q:

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

0

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

All Answers

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

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;
        }
}

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