-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpracticeset4.java
More file actions
46 lines (33 loc) · 981 Bytes
/
Copy pathpracticeset4.java
File metadata and controls
46 lines (33 loc) · 981 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
40
41
42
43
44
45
46
public class practiceset4 {
public static void main(String[] args) {
// QUESTION 1:write a program to find out whether a given integer is found in an array or not
// int arr[]={23,45,34,56,12,90};
// int a=12;
// for(int i=0;i<=arr.length-1;i++){
// if(a==arr[i])
// {
// System.out.println("The given number a is in array");
// break;
// }
// else{
// System.out.println("The given number is not present in an array");
// }
// }
//QUESTION 2:Crete a java program to add number of size 2,3
int arr[][]={{2,3,4},{4,5,6}};
int sum=0;
for(int i=0;i<arr.length;i++){
for(int j=0;j<arr[i].length;j++)
{
System.out.print(arr[i][j]);
}
}
for(int i=0;i<arr.length;i++){
for(int j=0;j<arr[i].length-1;j++)
{
sum=sum+arr[i][j];
}
System.out.println(sum);
}
}
}