i,j=0,*a1,temp;
a1=(int*)malloc((MAX-n)*sizeof(int));
for(i=n;i<MAX;i++)
*(a1+j++)=*(a+i);
*(a+n)=x;
for(i=n+1;i<MAX;i++)
*(a+i)=*(a1++);
for(i=0;i<MAX;i++)
printf("%d",*(a+i));
putchar(
);
}
OUTPUT
Enter an element to be inserted
66
Enter the position at which
this element to be inserted
3
11 22 33 66 44 55 77 88 0 0
a1=(int*)malloc((MAX-n)*sizeof(int));
for(i=n;i<MAX;i++)
*(a1+j++)=*(a+i);
*(a+n)=x;
for(i=n+1;i<MAX;i++)
*(a+i)=*(a1++);
for(i=0;i<MAX;i++)
printf("%d",*(a+i));
putchar(
);
}
OUTPUT
Enter an element to be inserted
66
Enter the position at which
this element to be inserted
3
11 22 33 66 44 55 77 88 0 0
0 comments:
Post a Comment