Computer Science, asked by brainy1358, 6 months ago

2.6 Write a program to take n integers from command line and
print their sum of product (product of first number and last
number added to product of second number and second last
number and so on).


programming language java​

Answers

Answered by Dapnne
1

Answer:

In java programme

Explanation:

mark me as brainliest

Attachments:
Answered by Maduboi
0

Answer:

Well I had the same question for a college test, here is the answer:

Explanation:

   public static void main(String[] args) {

       Scanner sc = new Scanner(System.in);

       System.out.println("How man numbers do you want?: ");

       int n = sc.nextInt();

       int[] a = new int[n];

       System.out.println("Enter " + n + " numbers: ");

       for(int i=0; i<n; i++) {

           a[i] = sc.nextInt();

       }

       System.out.println("The numbers are: ");

       for(int i=0; i<n; i++) {

           System.out.print(a[i] + ", ");

       }

       int sum = 0;

       for(int i=0; i<n/2 ; i++) {

           sum = sum + (a[i] * a[(n-1)-i]);

       }

       System.out.print("\nTheir sum of product is: " + sum);

   }

Similar questions