Can somebody help me why is this infinity loop in C?
I am actually solving a beginner questions from CodeForce(compitative programming) Question link: https://codeforces.com/problemset/problem/510/A But below code outputs infinity loop. My code: #include <stdio.h> #include <stdlib.h> int main() { int n=5,m=3;//row,column char board[n][m]; int i,j,side=0;//side is for in which side the hash(#) will be placed on the board int dotIndex;//dotIndex is positional value on a board where the dot(.) will be placed for(i=0;i<n;i+2) { for(j=0;j<m;j++) { board[i][j]='#'; printf("\ni = %d j = %d",i,j); } printf("\nStep 2"); if(side%2==0) { board[i+1][m-1]='#'; for(dotIndex=0;dotIndex<m-2;dotIndex++) board[i+1][dotIndex]='.'; } else{ board[i+1][0]='#'; for(dotIndex=1;dotIndex<m-1;dotIndex++) board[i+1][dotIndex]='.'; } printf("\nStep 4"); side++; } //Display board printf("\n"); for(i=0;i<n;i++) { for(j=0;j<m;j++) { printf(" %c",board[i][j]); } printf("\n"); } return 0; }