How it works...

Let's define a macro called max of size 20 and an array, arr, of size max, that is, 20 elements (you can increase the value of the max macro to any larger value as desired). Next, we will specify the length of the array. Let's say that the length you entered is 8, which is then assigned to the len variable. When prompted, enter the specified number of sorted elements. The sorted elements you enter will be assigned to the arr array, as follows:

Figure 9.1

Then, you will be prompted to enter the number you want to search for in the sorted array. Let's say you picked 45; this number will be assigned to the numb variable. We will ...

Get Practical C Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.