Assignment 7
Assignment 7
sub-SPM
Div-B
Assignment-7
Q-1)
import java.util.Scanner;
public class arry1
{
public static void main(String args[])
{
//search an element
Scanner sc=new Scanner(System.in);
System.out.println("enter the array length : ");
int n=sc.nextInt();
if(number[i]==number[j]&&i!=j)
System.out.println(number[i]);
}
//sum and product
int sum = 0;
int product = 1;
}
}
Name-Megh Patel
sub-SPM
Div-B
run:
enter the array length :
3
enter the array elements :
10
10
20
Array elements
10
10
20
duplicate element
10
Sum of the elements: 40
Product of the elements: 2000
Q-2)
import java.util.Scanner;
int commonIndex = 0;
if (array1[i].equals(array2[j]))
{
commonElements[commonIndex] = array1[i];
//System.out.println("coomon" + commonElements[commonIndex]);
commonIndex++;
}
}
}
run:
Enter the elements of the first array:
ab
ba
cc
Enter the elements of the second array:
ab
cc
ss
ab
cc
null
BUILD SUCCESSFUL (total time: 10 seconds)
Q-3)
import java.util.Scanner;
run:
Enter first string:
hello
Enter second string:
world
Concatenated string: helloworld