Write a C# program to calculate the sum of two integers and return true if the sum is equal to a third integer.
Source Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | class Program { public static bool sumoftwo(int p, int q, int r) { return ((p + q) == r || (q + r) == p || (r + p) == q); } static void Main(string[] args) { Console.Write("Input the first number : "); int x = Convert.ToInt32(Console.ReadLine()); Console.Write("Input the first number : "); int y = Convert.ToInt32(Console.ReadLine()); Console.Write("Input the first number : "); int z = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("The result is: " + sumoftwo(x, y, z)); Console.ReadKey(); } } |
Output:
You can find more similar examples of programming for this programming language in the site.