-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArrayUser.java
36 lines (28 loc) · 876 Bytes
/
ArrayUser.java
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
import java.util.Scanner;
class ArrayUser
{
public static void main(String arg[])
{
int iCnt = 0;
Scanner sobj = new Scanner(System.in);
System.out.println("Enter the size of array :");
int iSize = sobj.nextInt();
int Arr[] = new int[iSize];
System.out.println("number of elements in the array are :"+Arr.length);
for(iCnt = 0; iCnt < Arr.length; iCnt++)
{
Arr[iCnt] = sobj.nextInt();
}
System.out.println(("Elements of the array are :"));
for(iCnt = 0; iCnt < Arr.length; iCnt++)
{
System.out.println(Arr[iCnt]);
}
int iAns = 0;
for(iCnt = 0; iCnt < iSize; iCnt++)
{
iAns = iAns + Arr[iCnt];
}
System.out.println("addition is : "+iAns);
}
}