Program to do increment of 2 on all elements of an array using pointers.

#include<stdio.h>
main()
{

int i[3][3]= {
{1,2,3},
{3,4,5},
{5,6,7}
};

int *p,*q,*r,k;
printf("Adding 2 to all elements of the array.\nArray Becomes:\n");
p=&i;
for(k=0;k<9;k++)
{
printf("%d\n",*(p+k)+2);
}

}

Continue reading “Program to do increment of 2 on all elements of an array using pointers.”