2. Write a function deleteLast() that accepts an array and Delete the last element in the array and display
the contents of an array after deletion operation.
Answer:
Start function deleteLast(numbers[]):
for i as integer = arraySize-1 to arraySize do
numbers[i]=numbers[i+1]
arraySize=arraySize-1
Stop
3. Find an element x in an array and return the index of x, if found. Otherwise “print element x is not
in the list”.
Answer:
Start function FindElement(numbers[],x):
for i as integer = 0 to arraySize do
if numbers[i]==x then
return i
Print message: "The element x is not in the list"
return -1
Stop
4. Display the last 3 elements in the array
Answer:
Start function DisplayLast3Elements(numbers[]):
for i as integer = arraySize -3 to arraySize do
Display numbers[i]
Stop
Comments
Leave a comment