60 678
Assignments Done
97,7%
Successfully Done
In April 2018

# Answer to Question #58798 in C# for Lekorius Wallace

Question #58798
Write a program that asks the user to enter up to 20 integers.Store the integers in an array of longs. Then, the program should ask the user to enter an integer. The program should use the function Find_It()to locate the integer in the array. The third argument in Find_It() is the address of the found integer. The function should return 1 if the integer is found and 0 otherwise. If the integer is found, the program should replace the integer by its negative and display the elements in the array. If the integer is not found, display an appropriate message.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace array
{
class Program
{
static void Main(string[] args)
{
long[] array = new long[20];
for (int i = 0; i < 20; i++)
{
Console.WriteLine("Enter " +
(i+1) + " number of array");
}
Console.WriteLine("Enter number that you want to find");
int result = 0;
if (Find_It(array, numb, ref result) == 0)
{
Console.WriteLine("There is not this number in array");
}
else
{
array[result] *= -1;
foreach (long n in array)
{
Console.WriteLine(n);
}
}
}

public static int Find_It(long[] mas, int a, ref int res)
{

for (int i = 0; i < mas.Length; i++)
{
if (a == mas[i])
{
res = i;
return 1;
}
}
return 0;
}
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!