L
Learner177
Guest
this is my code it should work fine logically but somehow its not getting right value
below is the code:-
using System;
using System.Linq;
namespace JobTest
{
class Program
{
public int[] FuncArray(int[] arr,int n)
{
int counter=0;
int k =arr.Length;
for(int i=0;i<k;i++)
{
if(arr<=n)
{
counter += 1;
}
}
int[] numArray = new int[counter];
for (int i = 0; i < counter; i++)
{
if (arr <= n)
{
numArray = numArray + arr;
}
}
return numArray;
}
static void Main(string[] args)
{
Program p = new Program();
int[] evenNums= {1,5,0,1,7,4,10,3,9,16 }; // integer array
int[]res= p.FuncArray(evenNums, 7);
int len = res.Length;
for(int i=0;i<len;i++)
{
Console.Write(res);
}
}
}
}
it should print 1501743 but it prints this 1501740???
Continue reading...
below is the code:-
using System;
using System.Linq;
namespace JobTest
{
class Program
{
public int[] FuncArray(int[] arr,int n)
{
int counter=0;
int k =arr.Length;
for(int i=0;i<k;i++)
{
if(arr<=n)
{
counter += 1;
}
}
int[] numArray = new int[counter];
for (int i = 0; i < counter; i++)
{
if (arr <= n)
{
numArray = numArray + arr;
}
}
return numArray;
}
static void Main(string[] args)
{
Program p = new Program();
int[] evenNums= {1,5,0,1,7,4,10,3,9,16 }; // integer array
int[]res= p.FuncArray(evenNums, 7);
int len = res.Length;
for(int i=0;i<len;i++)
{
Console.Write(res);
}
}
}
}
it should print 1501743 but it prints this 1501740???
Continue reading...