import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
int N;
int temp = 0;
int[] A=new int [10];
Scanner input=new Scanner(System.in);
System.out.print("Enter the number of test cases: ");
int T=input.nextInt();
for(int x=0; x<T; x++){
System.out.print("Enter the number of elements in the array:" );
N=input.nextInt();
System.out.print("Enter the elements of the array: ");
for(int i=0;i<N;i++){
A[i]=input.nextInt();
}
int sum=A[N-1]+A[N-2];
System.out.println("Sum is: "+sum);
}
}}
Comments
Leave a comment