With two given lists [1,3,6,78,35,55] and [12,24,35,24,88,120,155], write a program to make a list whose elements are intersection of the above given lists.
Answers
Answer:
The program to find the intersection of the two list is as follows:-
class intersection
{
public static void main ( String args [ ] )
{
int index = 0 ;
int arr [ ] = new int [ 20 ] ;
int arr1 [ ] = new int [ 20 ] ;
int arr2 [ ] = new int [ 20 ] ;
for (int i = 0 ; i < 6 ; i + +)
{
for ( int j = 0 ; j < 7 ; j + + )
{
if ( arr1 [ i ] = = arr2 [ j ] )
{
arr [ count ] = arr [ i ] ;
count + + ;
}
}
}
}
}
Explanation:
Answer:
The program to find the intersection of the two list is as follows:-
class intersection
{
public static void main ( String args [ ] )
{
int index = 0 ;
int arr [ ] = new int [ 20 ] ;
int arr1 [ ] = new int [ 20 ] ;
int arr2 [ ] = new int [ 20 ] ;
for (int i = 0 ; i < 6 ; i + +)
{
for ( int j = 0 ; j < 7 ; j + + )
{
if ( arr1 [ i ] = = arr2 [ j ] )
{
arr [ count ] = arr [ i ] ;
count + + ;
}
}
}
}
}