Computer Science, asked by smrutiranibordhan600, 6 months ago

write a program to store 10 number each in two array and add their sum in 3rd array and display it . ​

Answers

Answered by lalitnit
0

Answer:

class SumOfArray{

public static void main(String args[]){

int[] array = {10, 20, 30, 40, 50, 10};

int sum = 0;

//Advanced for loop

for( int num : array) {

sum = sum+num;

}

System.out.println("Sum of array elements is:"+sum);

}

}

import java.util.Scanner;

class SumDemo{

public static void main(String args[]){

Scanner scanner = new Scanner(System.in);

int[] array = new int[10];

int sum = 0;

System.out.println("Enter the elements:");

for (int i=0; i<10; i++)

{

array[i] = scanner.nextInt();

}

for( int num : array) {

sum = sum+num;

}

System.out.println("Sum of array elements is:"+sum);

}

}

Similar questions