Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int Insertion_lastpositon (int b[],int nn, int vv);
- void linear_search(int b[],int nn, int vv);
- int main ()
- {
- int a[100],n,i,c,b=1,v,p;
- printf("\n Enter how many values\n");
- scanf("%d",&n);
- printf("\n Enter Values\n");
- for(i=1;i<=n;i++)
- scanf("%d",&a[i]);
- while (b)
- {
- printf("\n...........menu.......\n");
- printf("\n pres 0 for Quit\n");
- printf("\n pres 2 for insertion at last position\n");
- printf("\n pres 5 for linear search\n");
- printf ("\n Enter your choice\n");
- scanf("%d", &c);
- switch(c)
- {
- case 0:b=0;
- break;
- case 2: printf ("\n choice = Insertion at last position \n");
- printf("Enter new value \n");
- scanf ("%d",&v);
- n=Insertion_lastpositon(a,n,v);
- break;
- case 5: printf("\n choice =linear_search \n");
- if(n!=0)
- {
- printf("\n Enter Value for searching \n");
- scanf ("%d",&v);
- linear_search (a,n,v);
- }
- else
- printf("\n No Data to search \n");
- break;
- }
- }
- }
- int Insertion_lastpositon (int b[],int nn, int vv)
- {
- b[nn+1]=vv;
- printf("\n Inserted Sucessfully \n\n");
- return nn+1;
- }
- void linear_search(int b[],int nn, int vv)
- {
- int j,c=0;
- for(j=1;j<=nn;j++)
- {
- if (b[j]==vv)
- {
- printf("\n Found at position =%d \n",j);
- c=c+1;
- }
- }
- if (c==0)
- printf("\n Not Found \n");
- else
- printf("Total Found =%d \n",c);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement