#include<stdio.h>
int main() {
int a[100],n,pos,val,i;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
scanf("%d",&pos);
val=a[pos];
printf("deleted value is %d\n",val);
for(i=pos;i<n;i++)
{
a[i]=a[i+1];
}
n--;
printf("elements after deletion are\n");
for(i=0;i<n;i++)
printf(" %d",a[i]);
}
int main() {
int a[100],n,pos,val,i;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
scanf("%d",&pos);
val=a[pos];
printf("deleted value is %d\n",val);
for(i=pos;i<n;i++)
{
a[i]=a[i+1];
}
n--;
printf("elements after deletion are\n");
for(i=0;i<n;i++)
printf(" %d",a[i]);
}
i/p: 5
1 2 3 4 5
3
o/p:
deleted value is 4
elements after deletion are
1 2 3 5
No comments:
Post a Comment