-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patharray.java
30 lines (29 loc) · 908 Bytes
/
array.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
//write a java program to input the array element perform the addition,subtraction,multiplication,divison and display the result
import java.util.Scanner;
class array
{
public static void main(String[] args)
{
int a[]=new int[100],i,sum = 0,sub=0,n;
double mul=1,div=1;
Scanner ab = new Scanner(System.in);
System.out.println("enter the size: ");
n=ab.nextInt();
System.out.println("enter array elements: ");
for(i=0;i<n;i++)
{
a[i]=ab.nextInt();
}
for(i=0;i<n;i++)
{
sum=sum+a[i];
sub=sub-a[i];
mul=mul*a[i];
div=div/a[i];
}
System.out.println("sum is: " + sum);
System.out.println("subtraction is: " + sub);
System.out.println("multiplication is: " + mul);
System.out.println("divison is: " + div);
}
}