//program to change colour of blocks in 8*8 matrix according to the given specification. #include void changecolour(int a[][8],int r1,int c1,int r2,int c2, int count)// here we are sending the parameter count which will keep track of colour { if(r1==r2 && c1==c2) { a[r1][c2]=count%2; } else { changecolour(a, r1,c1, (r1+r2)/2, (c1+c2)/2, count+1);// we are incrementing the count means flipping the colour this is first block changecolour(a, r1,((c1+c2)/2) +1, (r1+r2)/2, c2, count); changecolour(a, ((r1+r2)/2) +1 ,c1, r2, (c1+c2)/2, count); changecolour(a, ((r1+r2)/2) +1 ,((c1+c2)/2) +1, r2, c2, count+1);// this is 4th block } } int main() { int i,j,a[8][8]; for(i=0;i<8;i++){ for(j=0;j<8;j++){ a[i][j]=0; } } changecolour(a,0,0,7,7,0); for(i=0;i<8;i++) { printf("\n"); for(j=0;j<8;j++) { printf("%d \t",a[i][j]); } } return 0; }