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, 8, 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));
int[] finalarray = arrayOfInteger;
int smallestvalue = 99999;
int incrementalValue = 0;
for(int i=0;i<arrayOfInteger.Length;i++)
result = arrayOfInteger[i].ToString();
for (int j =0;j<arrayOfInteger.Length; j++) {
if(arrayOfInteger[i] + arrayOfInteger[j] == targetNumber){
result = result + ", " + arrayOfInteger[j].ToString();
if(result.IndexOf(",") == result.Length-1){
Console.WriteLine("There are no numbers which can be summed to make the target number");
string response = result;