-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharray3.java
More file actions
31 lines (30 loc) · 930 Bytes
/
array3.java
File metadata and controls
31 lines (30 loc) · 930 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
import java.io.*;
class array3
{
static int i,s,n;
public static void main(String args[])throws IOException
{
BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
System.out.println("<<< ENTER THE TOTAL NUMBER OF ELEMENTS >>>");
n=Integer.parseInt(buf.readLine());
int a[]=new int[n];
System.out.println("<<< ENTER THE ELEMENTS OF THE ARRAY >>>");
for(i=0;i<n;i++)
{
a[i]=Integer.parseInt(buf.readLine());
}
System.out.println(" THE ARRAY IS ");
for(i=0;i<n;i++)
{
System.out.print(a[i]+" ");
}
System.out.println();
System.out.println(" THE ARRAY IN REVERSED ORDER IS ");
for(i=n-1;i>=0;i--)
{
s=s+a[i];
System.out.print(a[i]+" ");
}
System.out.println(" THE SUM OF THE ARRAY IS ....."+s);
}
}