0

How do I multiple my array1 to array2 in backward? and then multiple its product to array3 in backward also

for example: array1 = { 2, 4, 6, 8, 10, 12, 14, 16 } * array2 = { 1, 2, 3, 4, 5, 6, 7, 8 } expected output is {2, 8, 18, 32, 50, 72, 128} and how do I multiple this expected output to my array 3?

I only know how to store and display values inside my array so far here is my code:

            int[] array1 = { 2, 4, 6, 8, 10, 12, 14, 16 };
            Console.Write("\nArray 1: ");
            Console.WriteLine(String.Join(", ", array1));

            int[] array2 = { 8, 7, 6, 5, 4, 3, 2, 1 };
            Console.Write("\nArray 2: ");
            Console.WriteLine(String.Join(", ", array2));


            int[] array3 = { 3, 4, 3, 0, 1, 7, 4, 2 };
            Console.Write("\nArray 3: ");
            Console.WriteLine(String.Join(", ", array3));

            Console.Read();
2
  • What is your expected output? Commented Sep 21, 2021 at 3:47
  • Expected output is { 2, 8, 18, 32, 50, 72, 128} Commented Sep 21, 2021 at 3:49

1 Answer 1

2
Console.WriteLine(string.Join(",", array2.Reverse().Zip(array1, (a, b) => a*b)));

or

array3 = array2.Reverse().Zip(array1, (a, b) => a*b).ToArray();
Sign up to request clarification or add additional context in comments.

1 Comment

how can I multiple the output to array3?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.