Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Display_Array(int b[],int k);
- void Edit(int b[],int pp,int vv);
- int Insert_LastPosition(int b[],int nn,int vv);
- int Insertion_SpecificPosition(int b[],int nn,int vv,int pp);
- int Deletion(int b[],int nn,int pp);
- int main()
- {
- int a[100],n,i,c,b=1,v,p;
- printf("\n Enter how many value\n");
- scanf("%d",&n);
- printf("\n Enter value\n");
- for(i=1;i<=n;i++)
- scanf("%d",&a[i]);
- while(b)
- {
- printf("\n-----Menu----\n");
- printf("\n Press 0 for Quite\n");
- printf("\n Press 1 for Display\n");
- printf("\n Press 2 for Insertion at last position\n");
- printf("\n Press 3 for Insertion at specific position\n");
- printf("\n Press 4 for Delete from specific position\n");
- printf("\n Press 5 for Linear search\n");
- printf("\n Press 6 for Bubble Sort \n");
- printf("\n Press 7 for Binary Search\n");
- printf("\n Press 8 for Edit\n");
- printf("\n Enter your choice\n");
- scanf("%d",&c);
- switch(c)
- {
- case 0: b=0;
- break;
- case 1: printf("\n choice Display\n");
- if(n!=0)
- Display_Array(a,n);
- else
- printf("\n No data to display\n");
- break;
- case 8: printf("\n choice=Edit\n");
- if(n!=0)
- {
- printf("\n Enter new value\n");
- scanf("%d",&v);
- M: printf("Enter position between %d to %d\n",1,n);
- scanf("%d",&p);
- if (p>=1 && p<=n)
- Edit (a,p,v);
- else
- {
- printf("\n Wrong Position\n");
- goto M;
- }
- }
- else
- printf("No data to Edit\n");
- break;
- case 2:printf("\n Choice=Insertion at last position\n");
- printf("\n Enter new values\n");
- scanf("%d",&v);
- n=Insert_LastPosition(a,n,v);
- break;
- case 3:printf("\n Choice=Insertion at specification\n");
- if(n!=0)
- {
- k:printf("\n Enter position between %d to %d\n",1,n+1);
- scanf("%d", &p);
- if(p>=1 && p<=n+1)
- {
- printf("\n Enter new value \n");
- scanf("%d",&v);
- n=Insertion_SpecificPosition(a,n,v,p);
- printf("\n\n Inserted at position %d\n",p);
- }
- else
- {
- printf("\n Wrong position\n");
- goto k;
- }
- }
- else
- printf("\n The array is empty\n");
- case 4:printf("\n Choice=Delete from Array\n");
- if(n!=0)
- {
- z:printf("\nEnter Position between %d to %d",1,n);
- scanf("%d",&p);
- if(p>=1 && p<=n)
- {
- printf("\n Deleted value= %d\n",a[p]);
- n=Deletion(a,n,p);
- printf("\n Deleted sucessfully from position %d\n",p);
- }
- else
- {
- printf("\n Wrong position\n");
- goto z;
- }
- }
- else
- {
- printf("\n No data to Delete\n");
- break;
- }
- default: printf("\n wrong choice\n");
- break;
- }
- }
- }
- void Display_Array(int b[],int k)
- {
- int j;
- printf("\n The values are:\n");
- for(j=1;j<=k;j++)
- printf("%d\n",b[j]);
- }
- void Edit (int b[],int pp,int vv)
- {
- b[pp]=vv;
- printf("\n Edited Succesively\n");
- }
- int Insert_LastPosition (int b[],int nn,int vv)
- {
- b[nn+1]=vv;
- printf("\n Inserted successfully \n");
- return nn+1;
- }
- int Insertion_SpecificPosition(int b[],int nn,int vv,int pp)
- {
- int j;
- for(j=nn;j>=pp;j--)
- b[j+1]=b[j];
- b[pp]=vv;
- return nn+1;
- }
- int Deletion(int b[],int nn,int pp)
- {
- int j;
- for(j=pp;j<nn;j++)
- b[j]=b[j+1];
- return nn-1;
- }
Advertisement
Add Comment
Please, Sign In to add comment