How to write a C Program To Understand Use Of Pointers In MATRIX in C Programming Language ?
Solution For C Program :
/*C Program To Understand Use Of Pointers In MATRIX.*/
/*Accessing matrix elements & their address using pointer*/
#include<stdio.h>
#include<conio.h>
int i,j;
void main()
{
int mat1[3][3]={{11,12,13},{14,15,16},{17,18,19}};
clrscr();
printf("First Entered matrix is:\n");
for(i=0;i<3;i++)
{
printf("\n");
for(j=0;j<3;j++)
{
printf("\t%d",mat1[i][j]);
}
}
printf("\n\n Address of first row =%u",mat1);
printf("\n Address of Second row =%u",mat1+1);
printf("\n Address of Third row =%u\n",mat1+2);
printf("\n Address of\t(0,0) =%u",*(mat1+0)+0);
printf("\t (0,1) =%u",*(mat1+0)+1);
printf("\t (0,2) =%u",*(mat1+0)+2);
printf("\n Address of\t(1,0) =%u",*(mat1+1)+0);
printf("\t (1,1) =%u",*(mat1+1)+1);
printf("\t (1,2) =%u",*(mat1+1)+2);
printf("\n Address of\t(2,0) =%u",*(mat1+2)+0);
printf("\t (2,1) =%u",*(mat1+2)+1);
printf("\t (2,2) =%u",*(mat1+2)+2);
printf("\n\n Value at\t(0,0) =%d",*(*(mat1+0)+0));
printf("\t (0,1) =%d",*(*(mat1+0)+1));
printf("\t (0,2) =%d",*(*(mat1+0)+2));
printf("\n Value at\t(1,0) =%d",*(*(mat1+1)+0));
printf("\t (1,1) =%d",*(*(mat1+1)+1));
printf("\t (1,2) =%d",*(*(mat1+1)+2));
printf("\n Value at\t(2,0) =%d",*(*(mat1+2)+0));
printf("\t (2,1) =%d",*(*(mat1+2)+1));
printf("\t (2,2) =%d",*(*(mat1+2)+2));
getch();
}
You may also learn these C Program/Code :
C Program To Swap Two Numbers Without Using Third Variable
Learn More :
Matrix
- C Program To Find Transpose Of A Matrix
- C Program To Multiply Two Matrices
- C Program To Print Tridiagonal Matrix
- C Program : 4x4 Matrix Keypad connected to Arduino. This code prints the key pressed on the keypad to the serial port.
- C Code/Program For Swap Matrix
- matrix sort in C Program
- Sequential Matrix Multiplication C Program
- C Program to calculate sum of two m*n matrices & store the result in 3 matrix
- C Program to accept m*n matrix from user and display the elements of given matrix using function
- C Program to calculate the sum of elements of upper triangle of a n*n matrix using DMA
- C program to display the transpose of given 3 X 3 matrix
- Calculate sum of element of upper triangle of m*n matrix by using dynamic memory allocation
- Calculate sum of non-diagonal element in m*n matrix C Program
- Calculate sum of element of lower triangle of m*n matrix by using dynamic memory allocation
- C Program Shortest Distance in Matrix
- C Program To Read The Adjecancy Matrix of Directed Graph And Convert It Into Adjecancy List