getting WA in lebombs

here is my code. pl tell me where its going wrong. tried all test cases I could think of.


1 Like

Here is the modified version of your code, just changed one line and it worked. Select it as the answer of your question if it helped :slight_smile:

just change this

for(z=0;z<n;z++) //here i just changed this line for(z=0; finalstatus[z]!=’\0’, z++)

Complete modified code here


great,that worked. but i didn’t understand why the earlier “for(;finalstatus[z]!=’\0’;)” was wrong…??

1 Like

in c++ ‘\0’ doesn’t have any special meaning. So when you are using it in for loop, your console just ignores it and loop continues.

Whereas, in c ‘\0’ it represents a null character.

1 Like

using namespace std;

int main()
char a[8];
int k=0;
for(int i=0;i<8;i++)


return 0;


when u run this code,ull get output showing k has gone from 0 to 3(and not 7 or anything else). i ran this in codeblocks with gcc…so the ‘\0’ terminating condition has always been working on my pc…