Solved programming problem

Array Right Shifting in Java(One Index).

Source code

package javaapplication103;

import java.util.Scanner;

/**

 *

 * @author Sabit

 */

public class RightShift

{

     public static void main(String[] args)

    {

        int size;

        Scanner s = new Scanner(System.in);

        System.out.println("Enter Arrya Size: ");

        size = s.nextInt();

       

        int array[] = new int[size];

       

        System.out.println("Enter Araay Element: ");

        for(int i=0;i<size;i++)

        {

           array[i]=s.nextInt();

        }

 

        for(int i=0;i<1;i++)

        {

            int j=size-1;

           int temp = array[size-1];

           while(j>0)

           {

               array[j] = array[j-1];

               j--;

           }

           array[j]=temp;

        }

        System.out.println("Your Array after shifting 1 Right Index:");

        for(int i=0;i<size;i++)

        {

            System.out.print(array[i]+" ");

        }

        System.out.println("");

       

    }

}

Output

Enter array size:

Enter array elements:

1 2 3 4 5

Your array after shifting 1 Right Index:

5 1 2 3 4

Join the discussion

Add your comment

2 previous comments

Loupesy

We selected three recent microarray data of primary human breast cancer considering both high and moderate quality of gene expression, cancer cells content 60, patients number n 100, treatment regimen 2 3 rd untreated before surgery and previous survival association <a href=http://buylasixon.com/>taking lasix and still swelling</a>

CessyCary

Cialis Super Active Achat Avis [url=https://bestadalafil.com/]Cialis[/url] Rinqev Cialis Bugiardino Sycpyy The tentative diagnosis is a germ cell tumor of the testis. <a href="https://bestadalafil.com/">Cialis</a> Cialis Acquisto Farmacia Kicyua Vipps Certified Pharmacy https://bestadalafil.com/ - Cialis Withdraw the suspected medication aggressive rehydration and symptomatic management.