I am trying to return the integer array element after finding the 3 consecutive number problem please tell me where i am going wrong to return the array element inside from the loop.i want to return value in array and catch that element in another array.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace interview
{
class Program
{
static void Main(string[] args)
{
int[] arr = new int[5]{1,3,4,5,5};
int[] arr1 = GetOriginalScore(3,arr);
for (int i = 0; i < arr1.Length; i++)
{
Console.WriteLine(arr1[i]);
}
}
public static int[] GetOriginalScore(int input1, int[] input2)
{
for (int i = 0; i < input1; i++)
{
int a=((3 * input2[i] + 3) / 3);
if (a == (input2[i] + 1))
{
return input2[i];
}
}
}
}
}
please tell me where i am going to wrongdidn't the compiler tell you something as well? Or in what way do your expected results differ from the actual ones?