-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment.java
More file actions
39 lines (37 loc) · 869 Bytes
/
Assignment.java
File metadata and controls
39 lines (37 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package practicetime;
import java.util.*;
public class Assignment
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.print(" Enter the Length of the Array - ");
int n=sc.nextInt();
int a[]=new int[n];
System.out.print(" Enter the Elements - ");
for(int i=0;i<n;i++)
{
a[i]=sc.nextInt();
}
System.out.print("\n Elements of Array - ");
for(int i=0;i<n;i++)
{
System.out.print(a[i]+" ");
}
System.out.print("\n\n Enter the Number to Check the Sum - ");
int s=sc.nextInt();
System.out.print(" Pairs Are - ");
for(int i=0;i<n;i++)
{
for(int j=i+1;j<n;j++)
{
if(a[i]+a[j]==s)
{
System.out.print("("+a[i]+","+a[j]+") ");
}
}
}
System.out.println("\n\n Name - Piyush Kamal Anand \n UID - 16BCS1321 ");
sc.close();
}
}