Code: Select all

`if((a[i+1][j-1]=='*')&& i+1< m && j-1>= 0 )`

Code: Select all

`if(j-1>= 0 && i+1<m && (a[i+1][j-1]=='*'))`

**Another Idea:**

You can write a function which will return true if the position is valid and it contains a '*'. Suppose the function is valid(i,j). Then for any valid position(i,j) you can write

Code: Select all

`count = valid(i,j+1) + valid(i+1,j) + valid(i,j-1) + ...`

Hope these help.

P.S. Dont forget to remove your previous code.