Error in the output


sir I am not getting the sum at each level can you please help

else if (!q.empty()) {

                q.push(NULL);

                level++;

            }

this is wrong you have to do this condition only if temp is NULL
outside if condition
check the modified Code

Modified Code