#include<stdio.h>
main()
{
int a[10][10],i,j,m,n;
printf("\nEnter the order:");
scanf("%d%d",&m,&n);
printf("\nEnter the elements:");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
}
}
main()
{
int a[10][10],i,j,m,n;
printf("\nEnter the order:");
scanf("%d%d",&m,&n);
printf("\nEnter the elements:");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
scanf("%d",&a[i][j]);
}
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(i==j)
a[i][j]=1;
else
a[i][j]=0;
}
}
printf("\nThe unit matrix is:\n");
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("%d\t",a[i][j]);
}
printf("\n");
}
}
Thanks for sharing, the code sample is helpful for my work.
ReplyDelete2d data matrix barcode generator in java