Write code of your choice without any errors.
Saikrishna Vaddepally
2y
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 & answers
A Software Engineer was asked 1w agoQ. Tell me about JOIN queries.
A Software Engineer was asked 9mo agoQ. What is OOPS, and can you explain each of its core principles?
A Software Engineer was asked 9mo agoQ. Do you know how to create a user?
Popular interview questions of Software Engineer
A Software Engineer was asked 1w agoQ1. Tell me about JOIN queries.
A Software Engineer was asked 9mo agoQ2. What is OOPS, and can you explain each of its core principles?
A Software Engineer was asked 9mo agoQ3. Do you know how to create a user?
>
DXC Technology Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

