Hello,

So this question, I absolutely cannot get. Have been stuck here for hours

This is way too frustrating. I'm posting the question and my solution (REAL NOOB).

I have an exam in a few days and this question is probably nothing compared to what might be on it. Thanks a lot in advance!

The question is:

Get the number of rows and columns from the user for the matrix. Then ask the user to enter the characters for the matrix. Finally, display the value on the top, right corner of the matrix.

For example,

The letter "q" must be displayed for the 4X2 Matrix of:

a e c q

d c o n

My attempt:

Code:

#include<stdio.h>
main()
{
char **matrix;
int i,j;
int row,col;
printf ("Rows:");
scanf ("%d",&row);
printf ("\nColumns: ");
scanf ("%d",&col);
matrix=(char**)calloc(row,sizeof(char*));
for(i=0;i<col;i++)
matrix[i]=(char*)calloc(col,sizeof(char));
for(i=0;i<row;i++)
{
for(j=0;j<col;j++)
{
scanf("%s",matrix[i]);
if(matrix[i][j]==matrix[0][col-1])
printf("Top right corner is: %c",matrix[i][j]);
}
}
}