My output is not coming out right

I am unable to place ", " between 2 elements on the same level. Here’s my code: https://ide.codingblocks.com/s/654084

Hi @mitrapranav0027_5d705c8b616e0add,

You could modify the function like this,

cout<<"[";
    while(!q.empty()) {
        node*f=q.front();

        if(f==NULL) {
            q.pop();
            cout<<"]";

            if(!q.empty()) {
                cout<<", [";
                q.push(NULL);
            }
        }
        else {
            cout<<f->data;
            if(f->left) {
                q.push(f->left);
            }

            if(f->right) {
                q.push(f->right);
            }

            q.pop();
            if(q.front() != NULL){
                cout<<", ";
            }
        }

    }

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

you modify it between 2 elements on the same level by using code pro zone. Here’s my code which provide you the learning experience you deserve.