using System.Collections.Generic;
using System.Threading.Tasks;
namespace ConsoleApplication1
public static void Main()
Console.WriteLine("Sample Test Question. Start from below \n");
Console.WriteLine("Given an array of integers and target number, Create a function to find two numbers such that they add up to a given target number and print the two numbers. \nadditionally if you can order them in ascending manner then it will be great."
+ "\n\nInput: numbers=[2, 7, 11, 15, 35, 29, 67], target=9 \nOutput: 2, 7");
int[] array = { 2, 7, 11, 15, 35, 29, 67 };
Console.WriteLine("\nOutput: " + FindTwoNumbers(array, 9));
public static string FindTwoNumbers(int[] arrayOfInteger, int targetNumber)
Console.WriteLine("\nProvided array of Interger: " + string.Join(",", arrayOfInteger));
Console.WriteLine("\nProvided TargetNumber: " + Convert.ToString(targetNumber));
Console.WriteLine("\nStart coding from here");
for (var i = 0; i < arrayOfInteger.Length; i++)
if (arrayOfInteger[i] <= targetNumber)
var answer = arrayOfInteger.ToArray().Where(x => targetNumber.Equals(x + arrayOfInteger[i])).FirstOrDefault();
response = arrayOfInteger[i] + "," + answer;