Skip to content

Commit d3a9ff9

Browse files
authored
Merge pull request #66 from DushyanthaAT/main
ReverseArray.java
2 parents 89c336d + f1d9371 commit d3a9ff9

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

ReverseArray.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,22 @@
1111
*
1212
* @author Shanmuga Priya M
1313
*/
14-
public class reversearray {
15-
16-
/**
17-
* @param args the command line arguments
18-
*/
19-
public static void main(String[] args) {
14+
public static void main(String[] args) {
2015
int a[]=new int[10];
16+
int riv_a[]=new int[10];
2117
int n,i;
2218
Scanner obj= new Scanner(System.in);
23-
System.out.println("enter sizr of array");
19+
System.out.println("enter size of array : ");
2420
n=obj.nextInt();
25-
System.out.println("enter elements of array");
21+
System.out.println("enter elements of array : ");
2622
for(i=0;i<n;i++){
2723
a[i]=obj.nextInt();
2824
}
29-
for(i=n-1;i>=0;i--){
30-
System.out.println(a[i]);
25+
for(i=0;i<n;i++){
26+
riv_a[i]=a[n-1-i];
27+
}
28+
for(i=0;i<n;i++){
29+
System.out.println(riv_a[i]);
3130
}
3231
}
3332

0 commit comments

Comments
 (0)