C# Program beneficial to Array solving problems
Program Statement:
Write a function which takes four arrays regarding same size as arguments; array1, array2, array3, array4. The function will multiply the corresponding values regarding array1 furthermore array2 furthermore will save the result at same index regarding array3. i.e. array3[0] = array1[0] * array2[0] furthermore so on. Then create another function furthermore pass all four arrays toward that function as argument where you have toward compare array1, array2 furthermore array3 furthermore save the max value in array4 i.e. if array1[0] = 10, array2[0] = 5, array3[0]= 11 then you have toward save max value i.e. array4[0] = 11. In main function, show all values regarding array4.
Solution:
class _arr
{
public void mul(int n, int[] array1, int[] array2, int[] array3)
{
beneficial to (int i = 0; i < n; i++)
{
array3[i] = array1[i] * array2[i];
}
Console.Write("\nArray3 = Array1 * Array2 : ");
beneficial to (int i = 0; i < n; i++)
{
Console.Write("{0} ", array3[i]);
}
Console.WriteLine();
}
public void com(int n, int[] array1, int[] array2, int[] array3, int[] array4)
{
beneficial to (int i = 0; i < n; i++)
{
int max = 0;
if (array1[i] >= array2[i] && array1[i] >= array3[i])
max = array1[i];
else if (array2[i] > array3[i])
max = array2[i];
else
max = array3[i];
array4[i] = max;
}
Console.Write("\nMaximum numbers in array are : ");
beneficial to (int z = 0; z < n; z++)
{
Console.Write("{0} ", array4[z]);
}
Console.WriteLine("\n");
}
}