# /*Lab Cycle 9*/ #include<stdio.h> //#include<alloc.

h> void display(int *,int); void read(int *,int); void bubble_sort(int *,int); void insertion_sort(int *,int); main() { int *a,n,choice; //clrscr(); do { printf("\n1. Read\n2. Display\n3. Bubble Sort\n4. Insertion Sort\n"); printf("5. Exit\n"); printf("Enter yout choice "); scanf("%d",&choice); switch(choice) { case 1:printf("Enter no. of elements "); scanf("%d",&n); a=(int *)malloc(n*sizeof(int)); read(a,n); break; case 2:display(a,n); break; case 3:printf("After bubble sort \n"); bubble_sort(a,n); break; case 4:printf("After insertion sort \n"); insertion_sort(a,n); break; case 5:exit(); break; } }while(choice!=5); //getch(); } void read(int *a,int n) { int i; printf("Enter array elements "); for(i=0;i<n;i++) scanf("%d",(a+i)); } void display(int *a,int n) { int i; printf("\nThe array elements are \n"); for(i=0;i<n;i++) printf("%d ",*(a+i)); }

a[j]=a[j+1]. for(i=1.i<n. int n) { int i. } display(a.temp.i<n.n). for(i=0.i++) { pos=i.j<n-1. } void insertion_sort(int *a. pos--.pos.n).void bubble_sort(int *a. } display(a. temp=a[i]. } a[pos]=temp.j. } .i++) for(j=0. while(pos>0&&a[pos-1]>temp) { a[pos]=a[pos-1]. a[j+1]=temp.j++) if(a[j]>a[j+1]) { temp=a[j].int n) { int i.temp.