- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA912.java
More file actions
Latest commit
62 lines (52 loc) · 1.07 KB
/
Copy pathA912.java
File metadata and controls
62 lines (52 loc) · 1.07 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
importjava.util.Scanner;
classA912
{
publicstaticvoidmain(String[] args)
{
Scanners1 = newScanner(System.in);
System.out.println("--- Pgram will print first 10 PRIME num from given range in a REVERSE the DIGIT Order -----");
System.out.println("Enter the Start point");
intstart = s1.nextInt();
System.out.println("Enter the End point");
intend = s1.nextInt();
System.out.println();
intx=0;
inta[] = newint[10];
for (inti=start;start<=end ;start++ )
{
intk=2;
for (intj=k;k<=start ;k++ )
{
if (start%k==0 )
{
break;
}
}
if (start==k)
{
if (x<=9)
{
a[x++]=start;
}
}
}
// Reverse the digits of Array A
intz= a.length-1;
for (inti = 0;i<a.length ;i++ )
{
intnum =a[i];
a[i] = 0;
while(num>0)
{
intdigit = num%10;
a[i] = a[i]*10+digit;
num = num/10;
}
}
//Printing the reverse digit array
for (inti=0;i<a.length ;i++ )
{
System.out.print(a[i]+" ");
}
}
}