Guna
Guna
Question 1:
Input:
Array = [11, 22, 33, 44]
Task: Add the previous element to the current element.
Expected Output: [33, 55, 77, 99]
Question 2:
Input:
Array = [1, 5, 10, 15, 20]
Task: Add 5 to each element until the sum exceeds 50.
Expected Output: [1, 5, 10, 15, 20] (continue adding till sum exceeds 50)
Question 3:
Input:
Array = [10, 20, 30, 40, 50]
Task: Remove the last element and add 60 at the end.
Expected Output: [10, 20, 30, 40, 60]
Question 4:
Input:
Array = [7, 14, 21]
Task: Add 28 at the end.
Expected Output: [7, 14, 21, 28]
Question 5:
Input:
Array = [1, 2, 3, 4, 5]
Task: Remove the first element and add 6 at the start.
Expected Output: [6, 2, 3, 4, 5]
Question 6:
Input:
Array = [2, 3, 4]
Task: Add 1 at the start.
Expected Output: [1, 2, 3, 4]
Question 7:
Input:
Arrays = [[50, 60], [70, 80]]
Task: Combine both arrays.
Expected Output: [50, 60, 70, 80]
Question 8:
Input:
Array = [5, 10, 15, 20]
Task: Create a new array where each element is reduced by 5.
Expected Output: [0, 5, 10, 15]
Question 9:
Input:
Array = [11, 12, 13, 14]
Task: Filter the array to get only numbers that are odd.
Expected Output: [11, 13]
Question 10:
Input:
Array = [20, 30, 40, 50],
Task: Modify the array by adding 35 at index 2 without removing any element.
Expected Output: [20, 30, 35, 40, 50]
Question 11:
Input:
Array = [15, 20, 25, 30, 35]
Task: Extract a portion of the array from index 2 to 5
Expected Output: [25, 30, 35]
Question 12:
Input:
Array = [5, 10, 15, 20]
Task: Print each element divided by 5.
Expected Output:
1
2
3
4
Question 13:
Input:
String = "cat-dog-rat"
Task: Split the string by hyphens.
Expected Output: ['cat', 'dog', 'rat']
Question 14:
Input:
Array = ['this', 'is', 'a', 'test'],
Task: Join the array elements into a single string, separated by " - ".
Expected Output: "this - is - a - test"
Question 15:
Input:
Array = [5, 'a', true, null]
Task: Convert the array to a string.
Expected Output: "5,a,true,null"