C&S 2024 Exam - Question 1 (c)

 avatar
itsLu
c_cpp
a year ago
225 B
12
Indexable
#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