Display elements of Two Dimensional array through pointer

 Display elements of Two Dimensional  array through pointer


#include<stdio.h>

void main()

{

    int arr[2][3],row,col,i,*ptr;

    for(row=0;row<2;row++)

    {

        printf("\n Enter values of row %d ",row+1);

        for(col=0;col<3;col++)

        {

            scanf("%d",&arr[row][col]);

        }

    }//end of outer loop

    ptr=arr;

    printf("\n Elements of array are :");

    for(i=0;i<=5;i++)

    {

        printf("%d ",ptr[i]);

        //ptr++;

    }


   printf("\n\n Elements of array using pointer are: \n\n");

    for(i=1;i<=6;i++)

    {

        printf("%d ",*ptr);

        ptr++;

    }



}//end of main


Comments

Popular posts from this blog

How to Understand Programming and Learn Better ?

2 Dimensional Character Array in C and C++

Arrow Functions in Javascript