Hi Guys,

Wanted some help with my code.

This should be the OUTPUT.

Enter the size of your array: (array size should be 1-100)

Enter values of your array:

x[0]= (any integer)

x[1]= (any integer but not equal to the value of x[0])

x[2]= (any integer but not equal to the value of either x[0] or x[1])

and so on and so forth

it will then sort the array like the one below:

X[0]=1 x[1]=2 x[2]=3 ......

Enter Number to be Search: (any number either within the array elements or outside of it)

Here is the code below. Everything is working except to the part where it should prompt the user to enter another value for x if the value corresponds to either the values of other elements.

```
#include <stdio.h>
void main ()
{
int pass, found, fh, sh, mid, as,x[100],ctr,ns,j,temp;
printf ("\nEnter array size: ");
scanf ("%d",&as);
printf ("\nEnter the values of your array:\n ");
for (ctr=0;ctr<as;ctr++)
{
printf ("\nx[%d]= ", ctr);
scanf ("%d", &x[ctr]);
}
for (ctr=0;ctr<as-1;ctr++)
{
for (j=0;j<as-1;j++)
{
if (x[j]>x[j+1])
{
temp=x[j];
x[j]=x[j+1];
x[j+1]=temp;
}
}
}
printf ("\n\n--Sorted Series--\n\n");
for (ctr=0;ctr<as;ctr++)
{
printf ("\t x[%d]= %d", ctr,x[ctr]);
}
pass=0;
found=0;
fh=0;
sh=as;
printf ("\nEnter number to be search: ");
scanf ("%d", &ns);
do
{
mid=(fh+sh)/2;
if (ns<x[mid])
sh=mid-1;
else if (ns>x[mid])
fh=mid+1;
else
found=1;
pass++;
}
while (fh<=sh &&!found);
if (found)
printf("\nFound at index %d\n ",mid);
else
printf ("\nNot found\n");
printf("\n\nNumber of passes: %d\n\n ",pass);
}
```