Write a Program to Print MATRIX

//Code for PROGRAM TO PRINT MATRIX in C Programming

#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

Post a Comment

0 Comments