EmbLogic's Blog

Program to just insert element & display in 2d pointer.

#include<stdio.h>
#include<malloc.h>

int main()
{
int r,c,i,j,**p;

printf(“How many rows,you want to insert: “);
scanf(“%d”,&r);

printf(“How many columns,you want to insert: “);
scanf(“%d”,&c);

p=malloc(r*c*sizeof(int));

printf(“Enter your %d*%d matrix elements: “,r,c);
for(i=0;i<r;i++)

{
for(j=0;j<c;j++)

scanf(“%d\n”,&(*(*(p+i)+j)));
}

for(i=0;i<r;i++)
{
for(j=0;j<c;j++)
printf(“%d”,*(*(p+i)+j));
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>