डाउनलोड पी.डी.एफ. ई-बुक्स
Core Java - Addition Of Two Arrays

विवरण :

कोई विवरण नहीं है |


सोर्स कोड :

import java.util.Scanner;

public class AddArray
{
public static void main(String args[]){ 

int i;
int[] arr1= new int [10];
int[] arr2= new int [10];
int[] arr3= new int [10];

System.out.println("Enter 5 nos of 1st array\n");

for( i=0; i<5; i++){

Scanner enter = new Scanner(System.in);
arr1[i] = enter.nextInt();
}

System.out.println("Enter 5 nos of 2nd array\n");

for( i=0; i<5; i++){

Scanner enter = new Scanner(System.in);
arr2[i] = enter.nextInt();
}

for( i=0; i<5; i++){

arr3[i] = arr1[i] + arr2[i] ;
}

System.out.println("Addition of two arrays\n");

for( i=0; i<5; i++){

System.out.println(arr3[i]) ;
}

}
}

आउटपुट :

Enter 5 nos of 1st array

4
5
6
7
8
Enter 5 nos of 2nd array

4
5
6
7
8
Addition of two arrays

8
10
12
14
16