Spiral print(matrix) anticlockwise


I am getting a runtime error. What is the mistake?

I would suggest you to check for the underline mistakes in your code if you would ever face runtime errors.

1.Invalid memory access during run-time.
2.Accessing linked list nodes that do not exist.
3.Dividing by zero.
4.Large allocation of memory together/Large Static Memory Allocation.
5.Making a silly mistake.

In your code you have done the 5th mistake which is most common.

if(end_col>start_col)
{
for(i=end_row;i>=start_row;i–) //i should be decremented
{
cout<<a[i][end_col]<<", ";
}
end_col–;
}

mark your doubt resolved, is you are satisfied.

thanks a lot to point my mistake

Ur welcome.
Mark your doubt as resolved.
And you can also rate me and provide your reviews about me.

1 Like