From 8e058e677170479a0c4b3970f01bb5c187dfeaef Mon Sep 17 00:00:00 2001 From: abhishek kumar <92795729+Abhi19990628@users.noreply.github.com> Date: Fri, 29 Dec 2023 21:06:09 +0530 Subject: [PATCH] Create 2d.cpp two-dimensinol array --- 02-Pointer/enter elements of 2D array/2d.cpp | 24 ++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 02-Pointer/enter elements of 2D array/2d.cpp diff --git a/02-Pointer/enter elements of 2D array/2d.cpp b/02-Pointer/enter elements of 2D array/2d.cpp new file mode 100644 index 0000000..2ebc25f --- /dev/null +++ b/02-Pointer/enter elements of 2D array/2d.cpp @@ -0,0 +1,24 @@ +Following is the C program for pointers and two-dimensional array − + +#include +main ( ){ + int a[3] [3], i,j; + int *p; + clrscr ( ); + printf ("Enter elements of 2D array"); + for (i=0; i<3; i++){ + for (j=0; j<3; j++){ + scanf ("%d", &a[i] [j]); + } + } + p = &a[0] [0]; + printf ("elements of 2d array are"); + for (i=0; i<3; i++){ + for (j=0; j<3; j++){ + printf ("%d \t", *(p+i*3+j)); + } + printf (" +"); + } + getch ( ); +}