Solution to Write an algorithm, draw a flowchart and write a program code to display 3*3 Identity … - Sikademy
Author Image

Archangel Macsika

Write an algorithm, draw a flowchart and write a program code to display 3*3 Identity Matrix.

The Answer to the Question
is below this banner.

Can't find a solution anywhere?

NEED A FAST ANSWER TO ANY QUESTION OR ASSIGNMENT?

Get the Answers Now!

You will get a detailed answer to your question or assignment in the shortest time possible.

Here's the Solution to this Question

using namespace std;


//	Write an algorithm, draw a flowchart and write a program code to display 3*3 Identity Matrix.
#define N	3
int main()
{
	int I[N][N],r,c;
	
	cout<<"\n\t"<<N<<" x "<<N<<" Identity Matrix:\n";
	for(r=0;r<N;r++) 
	{
		for(c=0;c<N;c++)	
		{
			I[r][c] = 0;
			if(r==c) I[r][c] = 1;
			cout<<"\t"<<I[r][c];
		}
		cout<<"\n";
	}
	return(0);
}


//       Write an algorithm, draw a flowchart and write a program code to display 3*3 Identity Matrix.

Algorithm:

-        Define the Matrix Size as N

-        Initialize an Identity matrix I[N][N]  with NxN matrix size

-        Initialize a double for loop from r=0 to N and c=0 to N

-        if r==c,       I[r][c] = 1

else             I[r][c] = 0;

-        End the for loop

-        display the Identity matrix

-        end






Related Answers

Was this answer helpful?

Join our Community to stay in the know

Get updates for similar and other helpful Answers

Question ID: mtid-3-stid-44-sqid-1029-qpid-25