#include<stdio.h>#include<stdlib.h>int *a,n;void bubblesort();void swap_w(int,int);main(){ int i,j; printf("Enter the number of elements "); scanf("%d",&n); a=(int *)calloc(n,sizeof(int)); printf("Enter the elements\n"); for(i=0;i<n;i++) scanf("%d",a+i); bubblesort(0,n-1); printf("The sorted sequence is\n"); for(i=0;i<n;i++) printf("%d ",a[i]); printf("\n"); return;}void bubblesort(){ int i,j; for(i=0;i<n-1;i++) for(j=n-1;j>=i+1;j--)...
Wednesday, 12 March 2014
Subscribe to:
Posts (Atom)