Problem 68. C Program to print a diagonal matrix.
#include<stdio.h>
#include<conio.h>
main()
{
int a[4][4],i,j;
clrscr( );
for(i=0;i<4;i++)
for(j=0;j<4;j++)
if(i==j)
c[i][j]=7;
else
a[i][j]=0;
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
printf(“%d”,a[i][j]);
printf(“n”);
}
getch();
}
C compiler: gcc 4.1.2
Back to main directory: Sample C Program | Software Practical | Solved C Assignment#include<stdio.h>
#include<conio.h>
main()
{
int a[4][4],i,j;
clrscr( );
for(i=0;i<4;i++)
for(j=0;j<4;j++)
if(i==j)
c[i][j]=7;
else
a[i][j]=0;
for(i=0;i<4;i++)
{
for(j=0;j<4;j++)
printf(“%d”,a[i][j]);
printf(“n”);
}
getch();
}
C compiler: gcc 4.1.2