C Programming Tutorial

 
 
 
 
#include<stdio.h>
#include<conio.h>
void main()
{
    int i,j,d[10][10];
    clrscr();
    for(i=1;i<=10;i++)
    {
        for(j=1;j<=10;j++)
        {
            if(i==j)
            {
                d[i][j]=1;
            }
            else
            {
                d[i][j]=0;
            }
            printf(\"%d  \",d[i][j]);
        }
        printf(\"\\n\");
    }
    getch();
}

/*
       *********
    OUTPUT
       *********

       1  0  0  0  0  0  0  0  0  0
    0  1  0  0  0  0  0  0  0  0
    0  0  1  0  0  0  0  0  0  0
    0  0  0  1  0  0  0  0  0  0
    0  0  0  0  1  0  0  0  0  0
    0  0  0  0  0  1  0  0  0  0
    0  0  0  0  0  0  1  0  0  0
    0  0  0  0  0  0  0  1  0  0
    0  0  0  0  0  0  0  0  1  0
    0  0  0  0  0  0  0  0  0  1
*/

 
 
Didn't find what you were looking for? Find more on PROGRAM TO PRINT MATRIX