hi all,
I've done this code which has to book seats for a particular gala performance.
This should first scan the array for elements with flag[] = 0 and set flag[ ] =1 for the elements encountered then on upto the limit specified by 'num'. But it is not doing so...suggestions anyone?Code:main() { int flag[100], num; //num=number of seats booked at a time //flag[i]=1 for seats that are booked //flag[i]=0 for seats still available //initially all 100 seats are available for(int i=0;i<100;i++) flag[i]=0; printf("Enter the number of seats to be booked : "); scanf("%d",&num); int j=0; while(!flag[j]) { for(int k=0;k<num;k++) flag[k]=1; if (flag[k+num-j]==1) break; else { continue; j++; }