diff --git a/array/bubble_sort.cpp b/array/bubble_sort.cpp new file mode 100644 index 0000000..4681f38 --- /dev/null +++ b/array/bubble_sort.cpp @@ -0,0 +1,32 @@ +/* Bubble sort program using function and array +*/ +#include +#include +#include +#include "io.cpp" +using namespace std; +void bubble(int a[],int n){ + int i,j,temp; + for(i=0;ia[j+1]) + { + temp = a[j]; + a[j]= a[j+1]; + a[j+1]=temp; + } + } +} + +int main(){ + int a[10]; + //input phase + input(a,10); + //processing phase + bubble(a,10); + // output phase + cout<<"\n Sorted array :"; + output(a,10); + return 0; +} diff --git a/array/fun_array-4.cpp b/array/fun_array-4.cpp new file mode 100644 index 0000000..0038418 --- /dev/null +++ b/array/fun_array-4.cpp @@ -0,0 +1,38 @@ +/* array declaration + initialization from keyboard +*/ + +#include +#include +#include + +using namespace std; + +void fun_add(int a[],int n){ + int i; + for(i=0;i>a[i]; + } + + //processing phase + + fun_add(a,5); + + // output phase + + cout<<"\n Modified array :"; + for(i=0;i<10;i++) + cout< +#include +#include + +using namespace std; + +void output(int a[],int n){ + for(int i=0;i>x[i]; + } +} + +void fun_add(int a[],int n){ + int i; + for(i=0;i +#include +#include +#include "io.cpp" +using namespace std; +void fun_add(int a[],int n){ + int i; + for(i=0;i +#include +#include + +using namespace std; + +void output(int a[],int n){ + for(int i=0;i>x[i]; + } +} + +