**Zero cross** is the most common game that we can play anywhere , anytime with anybody. We evaluate the result by checking the matrix. Generally a tic tac toe game is played in a 3*3 matrix. You can see here c program for to evaluate winner for 3*3 matrix. But if we have a N*N board in which we are playing the game, for bigger board suppose for 50*50 matrix, it makes difficult to evaluate the actual and correct result. Here is the way to do so. You can also find other gaming code and all c program with different categories.

## c code for tic tac toe of N*N matrix to evaluate winner

#include<stdio.h> #include<conio.h> int main() { int n; int a[100][100]; printf(" ********** Zero One Match Result ************* \n"); printf("Enter the number of which you want to form N*N matrix \n"); scanf("%d", &n); //taking input for matrix dimension n=n-1; printf("Enter the zero one game values"); for(int i=0; i<=n; i++) { for(int j=0; j<=n; j++) { scanf("%d",&a[i][j]); //enter the values of in zero one form } if(i!=n) printf("%d row complete, enter %d row\n",i+1,i+2); } printf("\n******** Your board appear as *********\n"); for(int i=0; i<=n; i++) { for(int j=0; j<=n; j++) { printf("%d ",a[i][j]); } printf("\n"); } int i=0,d=1; while(a[i][i] == a[i+1][i+1] && i<n) //checking top left to right bottom diagonal { i++; if(i==n) { printf(" winner is %d",a[0][0]); d=0; } continue; } i=0; while(a[i][n-i]==a[i+1][n-i-1] && i<n) //checking top right to bottom left diagonal { i++; if(i==n) { printf(" winner is %d",a[0][n]); d=0; } continue; } for(int p=0; p<=n; p++) { i=0; while(a[i][p]==a[i+1][p]) //checking the columns { i++; if(i==n) { printf("winner is %d",a[0][p]); d=0; } continue; } i=0; while(a[p][i]==a[p][i+1]) //checking the rows value { i++; if(i==n) { printf("winner is %d",a[p][0]); d=0; } continue; } } if(d==1) printf("Match draw"); getch(); }

Output :

If you have any problem while compiling or understanding the code, do comment below and we will look upon that. Your suggestions are welcomed. Thank you.

Very easy and understandable code. Thank you so much ðŸ™‚