Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- //declaration
- void Display(int b[],int k);
- void Edit_Array(int b[],int nn,int pp,int vv);
- //2nd class upadte
- int Insertion_Lastposition(int b[],int nn,int vv);
- int Insertion_Specificaposition(int b[],int nn,int pp,int vv);
- int main()
- {
- int n,a[100],i,c,b=1,p,v;
- printf("\n How many values You want : \n");
- scanf("%d",&n);
- printf("\n Enter Your values : \n");
- //loop for array values
- for(i=1;i<=n;i++)
- scanf("%d",&a[i]);
- //menu while loop start
- while(b)
- {
- printf("\n------Menu -----\n");
- printf("\ntpress 0 for Quit\n");
- printf("\npress 1 for Display Your values Items\n");
- printf("\npress 2 for insertion at last position\n");
- printf("\npress 3 for insertion at Specific position\n");
- printf("\npress 4 for deletion at Specific position \n");
- printf("\npress 5 for Linear search\n");
- printf("\npress 6 Bubble sort\n");
- printf("\npress 7 Binary search\n");
- printf("\nPress 8 for Edit Your Values\n");
- scanf("%d",&c);
- // switch statement for choice Work
- switch(c)
- {
- case 0: b=0;
- break;
- case 1: printf("\n Choise=Display \n");
- if(n!=0)
- Display(a,n);
- else
- printf("\n The Array is Empty \n");
- break;
- //06-02-17
- case 2: printf("\n Chose = Insertion at last position \n");
- printf("\n Enter a New value");
- scanf("%d",& v);
- n=Insertion_Lastposition(a,n,v);
- break;
- case 3: printf("\n Choise=Insertion at specific position \n");
- if(n>0)
- {
- k: printf("\n Enter position between %d to %d _ ",1,n+1);
- scanf("%d",& p);
- if(p>=1 && p<=n+1)
- {
- printf("\n Enter new value_ \n");
- scanf("%d",& v);
- n=Insertion_Specificaposition(a,n,p,v);
- }
- else
- {
- printf("\n Wrong postion \n");
- goto k;
- }
- }
- else
- printf("\n Array is Empty \n");
- break;
- case 8:printf("\n Choise =Edit \n");
- //new edit rule start
- if(n>0)
- {
- M:printf("\n Choise position between %d to %d \n",1,n);
- scanf("%d",&p);
- if(p>=1&&p<=n)
- {
- printf("Enter value_ \n");
- scanf("%d",&v);
- Edit_Array(a,n,p,v);
- }
- else
- {
- printf("\n Wrong position you have enter \n");
- goto M;
- }
- }
- //new edit rule END
- else
- printf("\n NO data to edit \n");
- break;
- default: printf("\n Wrong choice you have Enter \n");
- }
- }
- return 0;
- }
- //defination
- void Display(int b[],int k)
- {
- int j;
- printf("\n The values are \n");
- for(j=1;j<=k;j++)
- printf("%d\n",b[j]);
- }
- //Edit_array defination
- void Edit_Array(int b[],int nn,int pp,int vv)
- {
- b[pp]=vv;
- }
- // insertion_lastposition defination
- int Insertion_Lastposition(int b[],int nn,int vv)
- {
- b[nn+1]=vv;
- printf("\n Inserted Sucessfully \n");
- return nn+1;
- }
- //inerstion_specifiaction new position
- int Insertion_Specificaposition(int b[],int nn,int pp,int vv)
- {
- int j;
- for(j=nn;j>=pp;j--)
- b[j+1]=b[j];
- b[pp]=vv;
- printf("\n Inserted at position %d",pp);
- return nn+1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement