Identity matrix is one in which whose rows and columns
are equal the value is 1 otherwise 0.
For Identity matrix code is
for(i=0;i<row;i++)
for(j=0;j<col;j++)
{
if (i==j)
a[i][j]=1;
else
a[i][j]=0;
}
Identity matrix is one in which where
row=col there will be one in all the other
places it will be zero.
This code may help U.
#include<stdio.h>
int main(void)
{
int row,col,i,j,a[10][10];
//please enter rows and columns equal.
printf("enter the number of rows")...
+=,-=,*=,/= are special type of assignment
operators.
E.g:- a+=b means a=a+b
a-=b means a=a-b
a*=b means a=a*b
a/=b means a=a/b
Thnak U for giving this opportunity.
Sparse matrix is one which consists of many
zero's in it. To reduce the memory we will convert
the matrix as sparse matrix.
E.g:- 1 0 0
0 2 0
3 0 0
The sparse mtarix for the above is
row cloumn value
1 1 1
2 2 2
3 1 3
For more details...
friend in earlier program
in the last for loop some mistake is there due
to typing mistake.
the last for loop in the program is
for(k=0;k<a;k++)
putchar('*');
but it should be
for(k=0;k<a[i];k++)
putchar('*');
sorry for the type of inconvience.
I hope the following Program may help U.
#include<stdio.h>
int main(void)
{
i,j,k,a[9]={1,3,5,7,9,7,5,3,1};
for(i=0;i<9;i++)//loop for stars
{
putchar('\n');
if(i<=4)
{
for(j=0;j<10-a[i]+i;j++)//loop for spaces for first 5 lines
putchar(' ');
}
else...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.