Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

BlueJ Program On Array And Reversing The Values In Array

 
Take 10 numbers in an array and reverse the numbers using a second function
e.g: input values 23  25  54 ……
        Output would be 32  52  45……….


import java.io.*;
class Ab
{
    BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
    int arr[]=new int [10];
       
    void show() throws Exception
    {
       int n;
       
       for(int i=0;i       {
           System.out.println("\nEnter Value: ");
           arr[i]=Integer.parseInt(br.readLine());
        }
        System.out.println("\nOriginal Value");
    for(int i=0;i       {
           System.out.print(" "+arr[i]);           
        }
        for(int i=0;i       {
       n=arr[i];
       arr[i]=reverse(n);
    }
    System.out.println("\nReversed Value");
    for(int i=0;i       {
           System.out.print(" "+arr[i]);           
        }   
        
    }
    private int reverse(int n)
    {
        int i,r=0;
        for(i=n;i>0;i=i/10)
        r=r*10+i%10;
        return r;
    }
    public static void main(String args[]) throws Exception
    {
       Ab obj=new Ab();
        obj.show();
    }
    
}


This post first appeared on Tutorial Site On Computer Programming Languages F, please read the originial post: here

Share the post

BlueJ Program On Array And Reversing The Values In Array

×

Subscribe to Tutorial Site On Computer Programming Languages F

Get updates delivered right to your inbox!

Thank you for your subscription

×