Binary search
Expand Post »this is a code for the binary search program in c language.now the program is not showing any error but when i run this program then the output is like:enter the total numbers:6
enter the array elements: 5 4 7 1 3 2
the sorted numbers are:1 2 3 4 5 7
enter the number to be searched:5
then it prints::::the number is not found
now why does it always print the number is not found no matter what number i enter.it always show "the number is not found"????why?????it is printing the sorted list alright.so why not the number then?plz help me out!!!!!!!!
C Syntax (Toggle Plain Text)
#include #include void main() { int a[10],n,i,j,temp; int beg,end,mid,target; clrscr(); printf(“enter the total numbers:�?); scanf(“%d�?,&n); printf(“enter the array elements:�? ); for(i=0;i) scanf(“%d�?,&a[i]); for(i=0;i-1;i++) { for(j=0;j-1;j++) {
No comments:
Post a Comment