From c3cd07538582381e2a88009f70fe067054a18a46 Mon Sep 17 00:00:00 2001 From: Kshitij Srivastav <63575990+kshitij-srivastav@users.noreply.github.com> Date: Sat, 3 Oct 2020 20:45:32 +0530 Subject: [PATCH] Ds lab program 1 Ds lab program 1 through C language --- program1.c | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 program1.c diff --git a/program1.c b/program1.c new file mode 100644 index 0000000..8ee4387 --- /dev/null +++ b/program1.c @@ -0,0 +1,85 @@ +#include +int a[20],n,ele,i,pos; + +void create() +//creating an array +{ +printf("\nEnter the size of the array elements:\t"); +scanf("%d",&n); +printf("\nEnter the elements for the array:\n"); +for(i=0;i (n+1)||pos<=0) +{ +printf("invalid position\n"); +return; +} + +for(i=n-1; i>=pos-1; i--) +a[i+1]=a[i]; +a[pos-1]=ele; +n++; +} + +void delete_ele() //deleting an array element +{ +printf("\nEnter the position of the element to be deleted:\t"); +scanf("%d",&pos); +if(pos>=n+1||pos<=0) +{ +printf("invalid position\n"); +return; +} +printf("element deleted is %d", a[pos-1]); +for(i=pos-1; i