﻿ C# Sharp exercises: Compute the sum of two given integers, if two values are equal then return the triple of their sum - w3resource

# C# Sharp Exercises: Compute the sum of two given integers, if two values are equal then return the triple of their sum

## C# Sharp Basic: Exercise-19 with Solution

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 Solution:

C# Sharp Code:

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

Sample Output:

```12
22
-3
```

Flowchart:

C# Sharp Code Editor:

Improve this sample solution and post your code through Disqus

What is the difficulty level of this exercise?

﻿

New Content: Composer: Dependency manager for PHP, R Programming