Created
May 12, 2024 13:14
-
-
Save jmichalenko/349856f4f68626ebd29c42abfaed89ed to your computer and use it in GitHub Desktop.
starter code for binarysearch lab
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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