Skip to content

Instantly share code, notes, and snippets.

@jmichalenko
Created May 12, 2024 13:14
Show Gist options
  • Select an option

  • Save jmichalenko/349856f4f68626ebd29c42abfaed89ed to your computer and use it in GitHub Desktop.

Select an option

Save jmichalenko/349856f4f68626ebd29c42abfaed89ed to your computer and use it in GitHub Desktop.
starter code for binarysearch lab
// implement binary search function
#include <cs50.h>
#include <stdio.h>
#define NUMBERS 9
bool bin_search(int value, int values[], int size);
int main(void)
{
int arr[] = {2, 4, 6, 7, 8, 11, 14, 18, 20};
int target = get_int("Enter a number: ");
if (bin_search(target, arr, NUMBERS))
{
printf("Found\n");
}
else
{
printf("Not found!\n");
}
}
bool bin_search(int value, int values[], int size)
{
// TODO
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment