11 comments:

  1. 10.
    10.


    import java.util.Scanner;
    public class JavaApplication9 {


    public static void main(String[] args) {

    Scanner obj=new Scanner(System.in);
    int n,i;
    System.out.println("enter the number of elements");
    n=obj.nextInt();
    int arr[]=new int[n];
    System.out.println("enter the array");
    for(i=0;i<n;i++)
    {
    arr[i]=obj.nextInt();
    }
    System.out.println("The array is=");
    for(i=0;i<n;i++)
    {
    System.out.println(arr[i]);
    }
    System.out.println("The reversed array is=");
    for(i=n-1;i>=0;i--)
    {
    System.out.println(arr[i]);
    }
    }

    }

    ReplyDelete
  2. import java.util.Scanner;

    class Test1{
    public static void main(String a[]){
    int ar[]=new int[100];
    int i,j,number;
    System.out.print("Enter the number of elements: ");
    Scanner o=new Scanner(System.in);
    number=o.nextInt();
    System.out.println("Now enter the values of array: ");
    for(i=0;i<number;i++){
    ar[i]=o.nextInt();
    }
    for(i=0,j=number-1;i<j;i++,j--){
    ar[i]+=ar[j];
    ar[j]=ar[i]-ar[j];
    ar[i]-=ar[j];
    }
    System.out.println("The reversed array is: ");
    for(i=0;i<number;i++)
    System.out.print("\t"+ar[i]);

    }
    }

    OUTPUT
    Enter the number of elements: 6
    Now enter the values of array:
    12 45 6 23 47 23
    The reversed array is:
    23 47 23 6 45 12

    ReplyDelete
  3. import java.util.Scanner;
    class ReverseArray
    {
    public static void main(String args[])
    {int temp=0,j,i;
    Scanner scan=new Scanner(System.in);
    System.out.println("How many number you want to add");
    int n=scan.nextInt();
    int ar[]=new int[n];
    System.out.println("Enter Numbers");
    for (i=0;i<n;i++)
    {
    ar[i]=scan.nextInt();
    }
    for(i=0,j=n-1;i<j;i++,j--)
    {
    temp=ar[i];
    ar[i]=ar[j];
    ar[j]=temp;
    }
    System.out.println("Reverse Array");
    for (i=0;i<n;i++)
    {
    System.out.print(ar[i]+" ");
    }

    }
    }

    ReplyDelete
  4. import java.util.Scanner;
    public class REVERSEARRAY
    {
    public static void main(String args[])
    {int temp;
    int i ,j;
    Scanner scan=new Scanner(System.in);
    System.out.println("enter size of array");
    int n=scan.nextInt();
    int ar[]=new int[n];
    System.out.println("Enter elements in array");
    for (i=0;i<n;i++)
    {
    ar[i]=scan.nextInt();
    }
    for( i=0 , j = n-1; i < j ; i++ , j-- )
    {
    temp=ar[i];
    ar[i]=ar[j];
    ar[j]=temp;
    }
    System.out.println("Reverse Array is now as follows :");
    for (i=0;i<n;i++)
    {
    System.out.print(ar[i]+" ");
    }

    }
    }
    OUTPUT:
    enter size of array
    5
    Enter elements in array
    12
    32
    65
    12
    4
    Reverse Array is now as follows :
    4 12 65 32 12

    ReplyDelete
  5. import java.util.Scanner;
    class Reversearray
    {
    public static void main(String Args[])
    {
    System.out.println("How many numbers you want to enter?");
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int AR[]=new int[n];
    int i,j,temp;
    System.out.println("enter the values");
    for(i=0;i<n;i++)
    {
    AR[i]=sc.nextInt();
    }
    for(i=0,j=n-1;i<j;i++,j--)
    {
    temp=AR[i];
    AR[i]=AR[j];
    AR[j]=temp;
    }
    System.out.println("reversed array is");
    for(i=0;i<n;i++)
    {
    System.out.println(AR[i]+" ");
    }}}

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. This comment has been removed by the author.

    ReplyDelete
  10. import java.util.Scanner;
    class Reversearray{
    public static void main(String a[]){
    int n;
    Scanner scan=new Scanner(System.in);
    System.out.println("Enter the size of array:");
    n=scan.nextInt();
    int arr[]=new int[n];
    System.out.println("Enter the values");
    for(int i=0;i=0;i--){
    System.out.println(arr[i]);
    }
    }
    }

    ReplyDelete
  11. import java.util.*;
    class Arrayrev{
    public static void main(String ar[]){
    Scanner s=new Scanner(System.in);
    int i,n;
    System.out.print("Enter the number of elements: ");
    n=s.nextInt();
    int a[]=new int[n];
    System.out.println("Enter the values: ");
    for(i=0;i=0;i--)
    {System.out.print(a[i]+" ");}
    }
    }

    ReplyDelete