Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Implemeting Identity matrix in C

Status
Not open for further replies.

OlesadeMontserrat

Programmer
Jul 20, 2000
2
0
0
GB
how can i implement the identity matrix in c?<br>and how can I display it?<br>can you please send me the code for it?<br>Many Thanks
 
Anna, i know this is you, i do not think it appropriate that you are trying to obtain code for your dissertation in this way.&nbsp;&nbsp;If you continue i shall be forced to fail your work.<br><br>Dr Nicolai N Vorobjov <br>
 
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(&quot;enter the number of rows&quot;);
scanf(&quot;%d&quot;,&row);
printf(&quot;enter the number of columns&quot;);
printf(&quot;%d&quot;,&col);
for(i=0;i<row;i++)//making identity matrix
for(j=0;j<col;j++)
{
if(i==j)
a[j]=1;
else
a[j]=0;
}
//printing identity matrix
for(i=0;i<row;i++)
{
printf(&quot;\n&quot;);
for(j=0;j<col;j++)
printf(&quot;%5d&quot;,a[j]);
}
}

Thank U respond immedietely.
 
Anna, I know this is you. If you continue to post code in this way instead of including it in your dissertation, I shall be forced to fail your work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top