Skip to content

Commit 69e4dfe

Browse files
authored
Array programs
how to find odd and even numbers from the given array={1,2,3,4,5,6,7,8} and we are expect output 1,3,5,7,2,4,6,8
1 parent 21b8947 commit 69e4dfe

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

work_program.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package work;
2+
3+
public class work_program {
4+
5+
public static void main(String[] args) {
6+
// given array
7+
//to find output: 1357 2468
8+
int a[]={1,2,3,4,5,6,7,8};
9+
for(int i=0;i<a.length;i++)
10+
{
11+
if(a[i]%2!=0)
12+
{
13+
System.out.print(a[i]+",");
14+
}
15+
}
16+
for(int i=0;i<a.length;i++)
17+
{
18+
if(a[i]%2==0)
19+
{
20+
System.out.print(a[i]+",");
21+
}
22+
}
23+
}
24+
}
25+
26+
27+

0 commit comments

Comments
 (0)