summaryrefslogtreecommitdiff
path: root/2522/CH19/EX19.3/exm19_3.sce
diff options
context:
space:
mode:
Diffstat (limited to '2522/CH19/EX19.3/exm19_3.sce')
-rwxr-xr-x2522/CH19/EX19.3/exm19_3.sce34
1 files changed, 34 insertions, 0 deletions
diff --git a/2522/CH19/EX19.3/exm19_3.sce b/2522/CH19/EX19.3/exm19_3.sce
new file mode 100755
index 000000000..91c2c0951
--- /dev/null
+++ b/2522/CH19/EX19.3/exm19_3.sce
@@ -0,0 +1,34 @@
+// page no 624
+// example no A.3
+// SUBTRACTION OF TWO NUMBERS
+clc;
+printf('Minuend: 23 \n');
+printf('Subtrahend: 52 \n \n')
+printf('BORROW METHOD \n \n');
+
+m=2*10+3; // minuend
+s=5*10+2; // subtrahend
+// subtraction of the digits in the first place results in
+a=3-2;
+// to subtract the digits in the second place a borrow is required from the third place. assuming 1 at third place.
+
+x=12-5; // with a borrowed 1 from the third place
+
+sub=10*x+a;
+printf('Subtraction= ')
+disp(sub);
+printf('this is negative 29, expressed in 10s complement. \n negative sign is verified by the borrowed 1 from the third place.');
+
+printf('\n \n 10s COMPLEMENT METHOD \n \n');
+
+// 9's complement of 52 is
+
+n=99-52;
+// add 1 to the 9's complement to find the 10's complement
+t=n+1;
+// add the 10's complement of the subtrahend(23) to minuend(52) to subtract 23 from 52
+a=m+t;
+
+printf('Subtraction= ');
+disp(a);
+printf('this is negative 29, expressed in 10s complement');