bipo143

4.01.2017

Feb 4th, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. #include<stdio.h>
  2. int Insert_Lastposition (int b[], int nn, int vv);
  3. void Edit(int b[], int pp, int vv);
  4. void Display_Array(int b[],int k);
  5. int main()
  6. {
  7. int a[100],n,i,c,b=1,p,v;
  8. printf("\n Enter how many values \n");
  9. scanf("%d",&n);
  10. printf("\n Enter values\n");
  11. for(i=1;i<=n;i++)
  12. scanf("%d",&a[i]);
  13.  
  14. while(b)
  15. {
  16. printf("\n------Menu------\n");
  17. printf("\n Press 0 for Quit \n");
  18. printf("\n Press 1 for display \n");
  19. printf("\n Press 2 for insertion at last pointer \n");
  20. printf("\n Press 3 for insertion at specific \n");
  21. printf("\n Press 4 for Delete from specific position \n");
  22. printf("\n Press 5 for Linear Search \n");
  23. printf("\n Press 6 for Bubble Sort \n");
  24. printf("\n Press 7 for Bainary Search \n");
  25. printf("\n Press 8 For Edit \n");
  26.  
  27. printf("\n Enter your Choice \n");
  28. scanf("%d",&c);
  29.  
  30. switch(c)
  31. {
  32. case 0:
  33. b=0;
  34. break;
  35.  
  36. default:printf("\n Wrong Choice ");
  37. break;
  38.  
  39. case 1:
  40. printf("\n Choice=Display \n");
  41. if(n!=0)
  42. Display_Array(a,n);
  43.  
  44. else
  45. printf("\n No Data to Display \n");
  46. break;
  47.  
  48. case 2:
  49. printf("\n Choice=Insert at last position \n");
  50. printf("Enter new value\n ");
  51. scanf("%d", & v);
  52. n= Insert_Lastposition(a,n,v);
  53. break;
  54.  
  55. case 8:
  56. printf("\n Choice =Edit\n");
  57. if(n!=0)
  58. {
  59. printf("\n Enter Now value \n");
  60. scanf("%d" ,&v);
  61. M:printf("Enter Position between %d to %d\n",1,n);
  62. scanf("%d",&p);
  63. if(p>=1 &&p<=n)
  64. Edit(a,p,v);
  65. else
  66. {
  67. printf("\n Worng Position \n");
  68. goto M;
  69. }
  70. }
  71. }
  72.  
  73.  
  74. }
  75. }
  76. void Display_Array(int b[],int k)
  77. {
  78. int j;
  79. printf("\n The display are: \n");
  80. for(j=1;j<=k;j++)
  81. printf("%d\n",b[j]);
  82. }
  83. void Edit(int b[], int pp, int vv)
  84. {
  85. b[pp]=vv;
  86. printf("\n Edited Successfully");
  87. }
  88. int Insert_Lastposition (int b[], int nn, int vv)
  89. {
  90. b[nn+1]=vv;
  91. printf("\n Inserted successfully \n\n");
  92. return nn+1;
  93.  
  94. }
Advertisement
Add Comment
Please, Sign In to add comment