rt
-
Upload
amit-singh -
Category
Documents
-
view
218 -
download
1
description
Transcript of rt
W
FMCA RBS COLLEGE,AGRA
DATA STRUCTURE USING C
ALGORITHM OF INSERTION OF AN ELEMENT AT DESIRE POSITION INTO AN ARRAY
STEP1:INTIALIZATION TEMP=NUM
STEP 2 : REPEAT WHILE TEMP>= POSITION
(1) ARR[TEMP]
(2) TEMP=TEMP-1
STEP 3:ARR[POSITION]=ELEMENT
STEP4:NUM=NUM+1
STEP5:RETURN(NUM) W.A.P TO INSERT & DISPLAY AN ELEMENT IN AN ARRAY AND TO INSERT AN ELEMENT AT A DESISED POSTION
#include
#include
#include
int a[10],i,n,p,m;
void insert(int[],int);
void display(int[],int);
int position(int[],int,int);
void main()
{
clrscr();
int c;
while(1)
{
printf("1 insert\n");
printf("2 display\n ");
printf("3 position\n");
printf("4 exit\n");
printf("\n enter the choce\n ");
scanf("%d",&c);
switch(c)
{
case 1:printf("\n enter the num\n ");
scanf("%d",&n);
insert(a,n);
break;
case 2:display(a,n);
break;
case 3: printf("\n enter the position\n ");
scanf("%d",&p);
printf("\n enter the number do you want insert particur postion\n");
scanf("%d",&m);
position(a,p,m);
break;
case 4: exit(0);
}
}
getch();
}
void insert(int a[],int n)
{
for(i=1;i