Sum Averages Sorting Search

Code for Binary search is not included now..

Codes for sum of numbers and taking its average is very trivial and you all should do it yourselves!!

Bubble Sort

/*------------------- Soring code for 1st sem ----------------*/

/* #include <iostream.h>*/

#include <stdio.h>

#include <math.h>

main()

{

int a[] = { 5, 8, 1, 9, 3 };

int i, j, temp;

int n=5;

printf("this is unsorted numbers \n");

for(i=0; i<5; i++)

{

printf("%d\n",a[i]);

}

printf("\n");

for(i=0; i<n-1; i++)

{ /* 1st for loop */

for(j=0; j<n-i-1; j++)

{ /*2nd for loop */

if(a[j] > a[j+1])

{ /*start sorting*/

temp = a[j];

a[j] = a[j+1];

a[j+1] = temp;

} /*end sorting*/

} /*2nd for loop ends */

} /* 1st for loop ends */

printf("this is sorted numbers\n");

for(i=0; i<5; i++)

{

printf("%d\n",a[i]);

}

return(0);

}

/*--------- code ends here -------------------*/