- Upvotes Received
- 0
- Posts with Upvotes
- 0
- Upvoting Members
- 0
- Downvotes Received
- 1
- Posts with Downvotes
- 1
- Downvoting Members
- 1
Hey guyz, I've done with some coding, actually I've to submit it in the project form, what the question arises is that I dnt know where and what's the mistake in the coding. please help me out. but it's necesaary to do traversing through linklist. My topic is 'Departmental store', … |
|
#include<stdio.h> #include<conio.h> void main(void) {#include<stdio.h> #include<conio.h> void main(void) { clrscr(); int item,lb=0,ub=9,mid; int DATA[10]={1,2,3,4,5,6,7,8,9,10}; int beg=lb;int loc;int end=ub; mid=(beg+end/2); for(int i=0;i<10;i++) { printf("%d",DATA[i]); printf("\nEnter item"); scanf("%d",item); while(DATA[mid]!=item &&beg<=end) { if(item<DATA[mid]) end=mid-1; else beg=mid+1; } mid=(beg+end)/2; } if(DATA[mid]==item) { loc=mid; else printf("loc is %d",mid); else printf("loc is null"); } getche(); } |