Oop Assinment#1: Submitted By: Adnan Haider REG NO: SP20-BSE-037 Section: Bse 3B DATE: 26-03-2020
Oop Assinment#1: Submitted By: Adnan Haider REG NO: SP20-BSE-037 Section: Bse 3B DATE: 26-03-2020
package firstlast6;
int arr[]={6,2,3,5,1,6};
if(arr[0] == 6 || arr[arr.length-1] == 6)
else
}}}
Q.2: Print “same” if the first and last index are same
package same;
int arr[]={6,2,3,5,1,6};
System.out.println("same:");
else
System.out.print("not same");
}}
Q.3 Create a new array in which all the values are left rotate:
public class Rotate {
leftRotatebyOne(arr, n);
int i, temp;
temp = arr[0];
arr[n-1] = temp;
{
Rotate rotate = new Rotate();
int arr[] = { 1, 2, 3, 4, 5, 6, 7 };
rotate.leftRotate(arr, 2, 7);
rotate.printArray(arr, 7);
Q.4 Add 10 to all the indexes of the array and save the result in new array and
display that new array
int arr[]={2,4,3,5,7};
arr[i]=i+10;