diff options
Diffstat (limited to '260/CH8/EX8.1/8_1.sce')
-rw-r--r-- | 260/CH8/EX8.1/8_1.sce | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/260/CH8/EX8.1/8_1.sce b/260/CH8/EX8.1/8_1.sce new file mode 100644 index 000000000..f604a0841 --- /dev/null +++ b/260/CH8/EX8.1/8_1.sce @@ -0,0 +1,31 @@ +//Eg-8.1
+//pg-365
+
+
+clear
+clc
+
+A = [-2 1 4 3 1.5];
+//printf('The given array is \n')
+
+exec('swap.sci')
+
+//disp(A)
+
+n = length(A);
+
+printf('The given array is \n')
+
+disp(A)
+
+for(i=1:n)
+
+ for(i=1:n-1)
+ if(A(i) > A(i+1))
+ [A(i),A(i+1)] = swap(A(i),A(i+1))
+ end
+ end
+end
+
+printf('\n\nThe array after arranging in ascending order using bubble-sort algorithm is\n')
+disp(A)
\ No newline at end of file |