-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathA912.java.bak
More file actions
62 lines (52 loc) · 1.06 KB
/
A912.java.bak
File metadata and controls
62 lines (52 loc) · 1.06 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
import java.util.Scanner;
class A912
{
public static void main(String[] args)
{
Scanner s1 = new Scanner(System.in);
System.out.println("--- Pgram will print first 10 PRIME num from given range in a REVERSE Order -----");
System.out.println("Enter the Start point");
int start = s1.nextInt();
System.out.println("Enter the End point");
int end = s1.nextInt();
System.out.println();
int x=0;
int a[] = new int[10];
for (int i=start;start<=end ;start++ )
{
int k=2;
for (int j=k;k<=start ;k++ )
{
if (start%k==0 )
{
break;
}
}
if (start==k)
{
if (x<=9)
{
a[x++]=start;
}
}
}
// Reverse the digits of Array A
int z= a.length-1;
for (int i = 0;i<a.length ;i++ )
{
int num =a[i];
a[i] = 0;
while(num>0)
{
int digit = num%10;
a[i] = a[i]*10+digit;
num = num/10;
}
}
//Printing the reverse digit array
for (int i=0;i<a.length ;i++ )
{
System.out.print(a[i]+" ");
}
}
}