CODE:
import java.util.*;
class Reverse1
{
public static void
main(String args[])
{
int i,n,temp;
Scanner sc = new
Scanner(System.in);
System.out.println("Enter
number of elements:");
n=sc.nextInt();
int a[]=new
int[n];
for(i=0;i<=n-1;i++)
{
System.out.print("enter a no:");
a[i]=sc.nextInt();
}
for(i=0;i<=(n-1)/2;i++)
{
temp=b[n-i-1];
b[n-i-1]=a[i];
a[i]=temp;
}
for(i=0;i<=n-1;i++)
{
System.out.println(a[i]);
}
}
}
OUTPUT:
No comments :
Post a Comment