Write any code of your choice without even a minor error.

Saikrishna Vaddepally
1y

import java.util.Scanner;

class RotateRight2 {

public static void main(String[] args) {

Scanner sc =new Scanner(System.in);

System.out.println("enter size of an array");

int size=sc.nextInt();

//Initialize array

int [] a = new int [size] ;

System.out.println("array elements");

for (int i=0;i<=a.length-1 ;i++ )

{

a[i]=sc.nextInt();

}

System.out.println("enter n value");

int n=sc.nextInt();

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

{

int first=a[0];

for (int j=1;j<=a.length-1 ;j++ )

{

a[j-1]=a[j];

}

a[a.length-1]=first;

}

System.out.println("rev num");

for (int i=0;i<=a.length-1 ;i++ )

{

System.out.println(a[i]);

}

}

}

Help your peers!
Add answer anonymously...
DXC Technology Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+

Reviews

4 L+

Interviews

4 Cr+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter