Answer to Question #284569 in C for nav

Question #284569

Consider a square matrix A of size Nx N and an integer X which is an element of A. Find the row number R and column number C of X in A, and calculate the sum of


1
Expert's answer
2022-01-04T01:10:08-0500
#define N 4
int main()
{
	int r,c,X;
	int Matrix[N][N]= 	{
						{2, 0, 3, 4},
						{1, 3, 15, 6},
						{2, 0, 9, 8},
						{3, 4, 5, 6}
					};
	X = 15;
	for(r=0;r<N;r++)    
	{
		for(c=0;c<N;c++)
		{
			if(X == Matrix[r][c]) printf("\n\tX = %d belongs to Row = %d, Col = %d",X,r,c);
		}
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS