#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,row,col,a[10][10];
clrscr();
printf("Enter the number of row :: ");
scanf("%d",&row);
printf("Enter the number of column :: ");
scanf("%d",&col);
if(row == col)
{
printf("\n");
printf("Desired matrix is \n\n");
for(i=1;i<=row;i++)
{
printf("\n");
for(j=1;j<=col;j++)
{
if (i == j)
printf(" 1 ");
else
printf(" 0 ");
}
}
}
else
printf("Must enter row and column equals \n");
getch();
}
/*
**********
OUTPUT
**********
Enter the number of row :: 9
Enter the number of column :: 9
Desired matrix is
1 0 0 0 0 0 0 0 0
0 1 0 0 0 0 0 0 0
0 0 1 0 0 0 0 0 0
0 0 0 1 0 0 0 0 0
0 0 0 0 1 0 0 0 0
0 0 0 0 0 1 0 0 0
0 0 0 0 0 0 1 0 0
0 0 0 0 0 0 0 1 0
0 0 0 0 0 0 0 0 1
*/