Problem (1)
Write a function called searchForLastOccurence that takes as parameters an array of integers, an integer
key value, and the array size. The function should search for the last occurrence of the key value in the
array and return its position in the array, OR return -1 if the value is not found in the array.
The function prototype is: int searchForLastOccurence(int arr[], int key, int size);
هذا السؤال مال تيتورال 1
وأنا جاوبت على السؤال
int searchforlastoccurence (int arr[],int key,int size)
{
int i;
for(i=0;i<size;i++)
if (arr=key])
return i;
else
return -1;
}
أتمنى يكون الجواب صح وأذا غلط صحح ليي شباب وبنات