C&S 2024 Exam - Question 1 (c)

itsLu avatar
itsLu
C++
01/09/2024 8:33 PM
225 B
32
Indexable
Never
#include <iostream>
using namespace std;

int linearSearch(int *arr , int arraySize , int key)
{
    for(int k = 0 ; k < arraySize ; k++)
    {
        if(arr[k] == key)
            return k;
    }
    return -1;
}
Editor is loading...
Leave a Comment